| Deutsch English Français Italiano |
|
<ddd3a0b59c95b5752b66f46348c96a6f8279d518@i2pn2.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: fir <profesor.fir@gmail.com> Newsgroups: comp.lang.c Subject: best approach for multithreading (?) Date: Sat, 30 Nov 2024 23:04:35 +0100 Organization: i2pn2 (i2pn.org) Message-ID: <ddd3a0b59c95b5752b66f46348c96a6f8279d518@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 30 Nov 2024 22:04:43 -0000 (UTC) Injection-Info: i2pn2.org; logging-data="674943"; mail-complaints-to="usenet@i2pn2.org"; posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0"; User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19 X-Mozilla-News-Host: news://i2pn2.org:119 X-Spam-Checker-Version: SpamAssassin 4.0.0 Bytes: 2941 Lines: 64 [i wropte it soem days back then to eventually post in a place when people can answer this but i dont get idea of such place so i post it here for now] tell me if you know somethin better approach for multithreading than this i mean i got discovered soem approach for multithreadng (i mean scheme how it probably should be done) and i wonder if there is something better than this (in real world) the appriach is based on call queue and needs (at least as a base) two keywoards 'adq' (add queue) and 'runq' (run queue) ewentually 'runqs' (run queue sequantially) 'runqp' (run queue in parrallel) adq just adds a given adress of a function and its arguments in queue which is close to stack, say for(int i=0; i<5; i++) adq__ foo(i); stores foo, 0 foo, 1 foo, 2 foo, 3 foo, 4 (40 bytes if foo is 32 bit adress, and i is 32 bit int) in ram runq then runs it (iterates and runs the functions) (both adq and runq are better implemented on language level, though they also probably can be implemented in some library) the thing is the runq dont need to run the things on one core and sequentially but it can just run the queue on as many cores as are avaliable no problem i think if those queued calls are not conflicting one witch another (like foo is draw_line_of_mandelbrot(i); ) but if the calls may be somewhat conflizting (on ram writes) there is an optio to add to addq also a number assigned to each call which will denote/mark this call to be not conflicting witch another call if the numbers are different and eventuallt be conflicting if the numbers are the same (like "1") then the cals of the same group should be run on one core in sequential but the other groups can each be called on its own core i did not used multithreading more than couple of days in my life so i know it slight but i never liked what i used to much and this approach seem to me best of what i heard.. so is it he best approach or there is something better? /fir