Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #145985
| From | Philipp Klaus Krause <pkk@spth.de> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Example uses for read-modify-write operations? |
| Date | 2019-09-04 14:35 +0200 |
| Organization | solani.org |
| Message-ID | <qkob37$3jf$2@solani.org> (permalink) |
| References | <qknvks$rgm$2@solani.org> <MAMbF.78233$gN2.1096@fx31.iad> <qko70n$r2$2@solani.org> <cae4d59e-a30b-46f5-83f0-3cc2f45d670d@googlegroups.com> |
Am 04.09.19 um 14:14 schrieb already5chosen@yahoo.com: > > I use it for simple parallel scheduler. > Imagine N jobs or "work items" that can be done independently in arbitrary order. Then there is a pool of M working threads. You have a variable CNT that points to the next unassigned work items in the list. A main thread initializes a CNT, fires working threads and waits for their completion. Each working thread runs in a loop. At the beginning of the loop it does idx=Fetch-and-Add(CNT). If idx >= N then working thread exits otherwise it processes work item # idx and continues to the beginning of the loop. That's about all. Apart of multiple details. > Thanks for giving a real-world example use of fetch-and-add. From what I've read, fetch-and-add ist the most widely used of the RMW operations. Are there algorithms where one of the others occurs naturally (excluding obvious rewrites of algorithms to use fetch-and-subtract intead of fetch-and-add)? Philipp
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 11:20 +0200
Re: Example uses for read-modify-write operations? Clifford Heath <no.spam@please.net> - 2019-09-04 20:44 +1000
Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 13:26 +0200
Re: Example uses for read-modify-write operations? Clifford Heath <no.spam@please.net> - 2019-09-04 22:13 +1000
Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 14:33 +0200
Re: Example uses for read-modify-write operations? already5chosen@yahoo.com - 2019-09-04 05:14 -0700
Re: Example uses for read-modify-write operations? Philipp Klaus Krause <pkk@spth.de> - 2019-09-04 14:35 +0200
Re: Example uses for read-modify-write operations? mark.bluemel@gmail.com - 2019-09-04 08:24 -0700
Re: Example uses for read-modify-write operations? already5chosen@yahoo.com - 2019-09-04 08:37 -0700
Re: Example uses for read-modify-write operations? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-04 17:10 +0100
Re: Example uses for read-modify-write operations? Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-04 14:28 +0200
csiph-web