Article View: comp.lang.c
Article #2217Re: theoretically considering multithreading
From: fir
Date: Fri, 04 Dec 2026 22:40
Date: Fri, 04 Dec 2026 22:40
182 lines
8244 bytes
8244 bytes
fir pisze:
> fir pisze:
>> fir pisze:
>>> fir pisze:
>>>> fir pisze:
>>>>> fir pisze:
>>>>>> fir pisze:
>>>>>>> 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
>>>>>>>
>>>>>> async seems wrong as it is non symetrucal where async call is
>>>>>> symetrical to its parent thread imo so it like shows c needs an
>>>>>> operator "|" for paralelisation
>>>>>
>>>>> let see if it is right and such sole | will suff ice
>>>>>
>>>>> in simplicity it is like that
>>>>>
>>>>> for(;;)
>>>>> {
>>>>>
>>>>> blit(buff1) | memset(buff2, 0, buff2_len);
>>>>> swap(buff1, buff2);
>>>>>
>>>>> }
>>>>>
>>>>> blitt first buffer parellelly to clearing the second one
>>>>> then swap
>>>>>
>>>>>
>>>>> so in short it seems to be ok - sole | could stand for a basic
>>>>> paralelisation in c
>>>>>
>>>> ((that was) another neat c discovery)..adding for some who lie iam
>>>> not doin science
>>>
>>> especially bonita consider neat | for parallelisation in deeper c
>>> comparing to horrible c++ crap for it
>>>
>>> and im a holder of c spirit and tradition (at least partially) so
>>> belive me it belong to c tradition not to c++ s**t
>>>
>>> (though im also slightly joking but not fully becouse measuring how
>>> much it strictly belong to c tradition is hard)
>>
>> i remember i was once writing some notice that some small code like
>>
>> a = a +2; b = b/3; c=a+2;
>>
>> some pices are like able to be send tos eparate chanlesĀ and some not
>> but i was ot seiing it as clearly as her just showed... c needs
>> pararlel sepaator
>> like sa "," is sewuantial makingĀ a,b,c,d,e,f,g,h; run sequaintially
>> when some may be run para lelly so just parallem separator mighy be |
>> or other unicode apt sign
>>
>> a|b|c,d|e|f|g,h;
>> would mean those six pieces are run paralelly...
>>
>>
>> on such micro level im not sure if it would be usefull, but to spare
>> those async/avait on more macro level imo for sure
>
> especially this could be used in memset - if it really works that way
> that two cores have its separate ram acces thos double memory bandwidth
> (and this imo probablu must work that way instead other code would be
> not much usable) so
>
> memset(buf,0,1024*1024*16);
>
> coulde be written
>
> memset(buf,0,1024*1024*8) | memset(buf+1024*1024*8,0,1024*1024*8)|;
>
>
> some would say its dwelling in low lewel..but what could i say, it just
> seems that this multithreading dwells in low lewel in present times
>
>
> and if im wrong here soem may correct me
>
here quiestion is ofc implemetation becous imo it shouldnt go thru
libraries and system but just on assembly lelvel where one core should
just point second core to such memset and the core who ends first should
go in halt mode then another if ends should check if other ended nd if
its main go further and if its secondaru go sleep and wake up the main
Technical Details
Message-ID:
<11evfgl$24e8k$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!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-mailReferences:
<11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me> <11eukpq$1mcr3$1@dont-email.me> <11euksi$1mcr3$2@dont-email.me> <11eulc1$1mn8b$1@dont-email.me> <11eulh7$1mn8b$2@dont-email.me> <11eum4i$1n3mo$1@dont-email.me> <11eumkc$1ndh9$1@dont-email.me> <11eun0i$1nj2o$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!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 23:40:21 +0100 Organization: A noiseless patient Spider Lines: 182 Message-ID: <11evfgl$24e8k$1@dont-email.me> References: <11eu368$1d4cq$1@dont-email.me> <11eujsu$1lnub$1@dont-email.me> <11eukpq$1mcr3$1@dont-email.me> <11euksi$1mcr3$2@dont-email.me> <11eulc1$1mn8b$1@dont-email.me> <11eulh7$1mn8b$2@dont-email.me> <11eum4i$1n3mo$1@dont-email.me> <11eumkc$1ndh9$1@dont-email.me> <11eun0i$1nj2o$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 04 Dec 2026 22:40:22 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2242836"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tVmTAH+M2TzVVOY4Ssqaadbvb4F/2brE="; 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:1WWCN++ptB1uwoa31n0Suh1sBVc= sha256:d5AMfgcB+Uj6A2rJZFqaAIJs7/GK2dM5+LvcLWKEVtY= sha1:d8jYkcCQFhSpuXFpSmwVxV0G72I= sha256:96pr+umv4SeI1i0XJc2AZTswCbfNZuEQpc780Oc8C9g= In-Reply-To: <11eun0i$1nj2o$1@dont-email.me>