🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2200

Re: theoretically considering multithreading

#2200
From: Ross Finlayson
Date: Fri, 04 Dec 2026 17:06
101 lines
4708 bytes
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.

Technical Details
Message-ID: <PpicnfCjtIeUbo_2nZ2dnZfqn_ednZ2d@giganews.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me> <11eukpq$1mcr3$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 04 Dec 2026 17:06:17 +0000
Subject: Re: theoretically considering multithreading
Newsgroups: comp.lang.c
References: <11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me>
 <11eukpq$1mcr3$1@dont-email.me>
From: Ross Finlayson <ross.a.finlayson@gmail.com>
Date: Fri, 4 Dec 2026 09:06:12 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <11eukpq$1mcr3$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <PpicnfCjtIeUbo_2nZ2dnZfqn_ednZ2d@giganews.com>
Lines: 101
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-2N6ROaZjz/b9KTo7uY4unmqriwEQSFpRXy3epWTC6A7hMbDzGEtDBo6X7vHpSAYql/WBGPTFltJxSt0!tL0+2PUoZhLMgGC6/YBOZVm0FzDFqQJpEFuVBdyZNPCkc8PQRohIRbJPQZQG2pLE8i8FzmzaPBE=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40