🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2207

Re: theoretically considering multithreading

#2207
From: fir
Date: Fri, 04 Dec 2026 19:07
141 lines
6335 bytes
Ross Finlayson pisze:
> On 12/04/2026 07:04 AM, fir wrote:
>> fir pisze:
>>> fir pisze:
>>>> as i said i dont do multithreading as it makes code rigid so i culd
>>>> eventually implement it but as a last step not to complicate a code
>>>> which is not about multithreading
>>>>
>>>> but i eventually could consider it theoretically right now
>>>>
>>>> my 'system' (rasterizer/game) loop looks like that
>>>>
>>>> dispatch_events()  //0.2 ms (light set some variables)
>>>> clear_frame_bitmap() // 1 ms (primitive memset)
>>>> clear_depth_buffer() // 1ms  (primitive memset)
>>>> run_bag()   //1 ms (change positions exacute some creations and
>>>> deletions)
>>>> draw_bag()   // 12 ms  (heavy calls cliping and drawing rasterisation)
>>>> blit_frame() //1 ms
>>>>
>>>> those times are orientational i mean it depends on resolution ..the
>>>> higher frame resolution the more time sole clears consume
>>>>
>>>> and honestly 2 clear and blit are quite noticable (2.5 ms in sum in
>>>> lowres)
>>>>
>>>> i not insepcted it at the moment but probably run_bag() and draw_bag()
>>>> may be seen independant this way that i can callanother run bag when
>>>> it is yet rendered
>>>>
>>>> also i think if i would use switching pointers to frame and depth
>>>> buffers then ui can clear them where second thread draws them
>>>>
>>>> so i think i cal just cal 2 clears and run_bag on one therad..than
>>>> call draw not wait on its ending and switch pointers and run 2 clears
>>>> and
>>>> run_bag in parallel then wait unti draw_bag ends and call it
>>>> immediatelly, yer maybe even  calling blit in parallel
>>>>
>>>>
>>>> some opinions how to exactly do that (in winapi preferably)
>>>>
>>>>
>>>> this is a theoretical topic in a sense i wouldnt probably do that
>>>> right now but proabably will do it in some future
>>>>
>>>> if that would work that would help especially in higher resolutions
>>>> where clears+blit become really heavy or/and in case when run_bag
>>>> would be heavy (if i got more objects and more collision detections)
>>>>
>>>>
>>>>
>>> btw as c has keywords like while continue until (until maybe he has
>>> not but in some dream fog hed until is like in c imo)
>>> so imo it seems that such keyword would fit to wait until some async
>>> branch executes fulle
>>>
>>>
>>> async foo(); //call asynchronnously
>>>
>>>   do_smth();
>>>
>>> after foo;  // ???
>>>
>>> dont know if koncept to add few keywords toc  to encpsulate threading
>>> is stupid or wise
>>>
>>>
>>> it seems thought it can be considered
>>>
>>
>> in such case how this coulde would look like
>>
>>         clear_and_run_bag();
>> async draw_bag_and_blit(); //can draw
>>         clear _and_run_bag(); //clear and run parrallel to draw
>> after draw_bag_and_blit; //wait until both done
>>    async draw_bag_and_blit(); //may imediatelly draw again
>>      clear _and_run_bag();  /// also run
>>
>> but wait there is an error here as i cant draw bag whch is working so i
>> need also copy of a bag
>>
>> aloso this above suggest some simplicity is needed above as it dont look
>> natural
>>
>> its maybe more
>>
>>
>> for(;;)
>>         clear_and_run_bag() | draw_bag_and_blit(); //run those in
>> parallel and wait to both
>>
>>
>>
>>
>>
> 
> 
> "Double-buffering" is the usual idea.
> 
> 

as far as i remember double buffering was for something other

on slow microcomputers when you drawed to the screen it was slow so it 
was simply visible thus you needed second buffer to render and
the to "switch "fast to screen

in my 'system' there is llike builtin double buffering as windows
bitmap data - this one that is contents of window is not the ram i 
generate frame - so i need to "blit" one into another and it is so 
called blitter ..blitter based genre is whole 'genre' - exactly what i 
am doing

here i would need more buffers just to clear two when i use other two
(as even clearing is notable as its slow..


overally my rasterizer drawing time is dominant but i made an experiment
and added just 25x25x15 pixels as cosmic  "dust" - just to be pushed
by ship..and digging tunnels in it and sadly it gets slow quite 
immediatelly becouse if more 3d objects come than phisics part become 
dominated

https://www.youtube.com/watch?v=CXgjWhoayPU

note this video is traumatic to see as things slow down here
(for some reason, i dont exactly kno why, some explosion appeared
in other place os space and probably it resized bag of objects
geomatrically and it slowed things down and i forgot to enable 
compacting (if that is a reason)



thats why i would live in world when computers are much raw faster as i 
do especialy write very easy codes but for large sets of things



Technical Details
Message-ID: <11ev31f$1tssb$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me> <11eukpq$1mcr3$1@dont-email.me> <PpicnfCjtIeUbo_2nZ2dnZfqn_ednZ2d@giganews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: theoretically considering multithreading
Date: Fri, 4 Dec 2026 20:07:26 +0100
Organization: A noiseless patient Spider
Lines: 141
Message-ID: <11ev31f$1tssb$1@dont-email.me>
References: <11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me>
 <11eukpq$1mcr3$1@dont-email.me>
 <PpicnfCjtIeUbo_2nZ2dnZfqn_ednZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 04 Dec 2026 19:07:28 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2028427"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/6apgj6KJ+a8fn0hVPRgPNUCRUBRJmdQs="; posting-host="1694223590bb8076180e0a28306e4e97"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:1V4xw7P37U4FvrhBZlc9p8jOHc8= sha256:QcYvdfyyN+NEk7qjZ4+iXVUFHIcKK7SJEWBz/JDeVPA=
	sha1:httvT2wY62qpkBZxFqb8XuLap6k= sha256:w+LNA8HMxV2Bft9hO1NqjO1dakyVxMrqYzOscWfp/jw=
In-Reply-To: <PpicnfCjtIeUbo_2nZ2dnZfqn_ednZ2d@giganews.com>