Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #67835
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: "volatile" on variables and current processors |
| Date | 2019-08-20 23:10 -0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <qjin8t$12np$1@gioia.aioe.org> (permalink) |
| References | (1 earlier) <qjf7bo$ori$1@redfloyd.dont-email.me> <qjf7dm$ori$2@redfloyd.dont-email.me> <qjfbr4$l1t$1@gioia.aioe.org> <qjhmsv$3jk$3@dont-email.me> <qjimqh$41i$1@dont-email.me> |
On 8/20/2019 11:02 PM, Paavo Helde wrote: > On 20.08.2019 23:58, Vir Campestris wrote: >> >> I know what the code ought to be. It ought to be re-written in C++ using >> atomics (and in several cases other library features - I noticed a >> spin-lock) >> >> But it's big. It isn't going to be rewritten unless it's proved to be a >> problem. And proving this would be hard - it'll be a race condition >> somewhere. > > Race conditions are not so hard to demonstrate, especially when you know > where the problem is. Just make a volatile integer counter with initial > value one, then let your 4 cores increase and decrease it in tight loops > in parallel. Whenever the counter drops to zero or below you have > demonstrated the race condition. Indeed. :^) > Should happen in seconds or minutes, > but my experience is from Intel, not ARM, so YMMV. > > BTW, the above is an extract from a real life scenario where the counter > mimics a smartpointer reference counter. In real life the effects are > much more fun - the pointed object will be released when the refcount > drops to zero, so the next non-trivial member function call to it will > probably segfault. This kind of behavior might make the demo a bit more > convincing ;-) > Kind of reminds me of creating a rng using race-condition's: https://groups.google.com/d/topic/comp.lang.c++/7u_rLgQe86k/discussion
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
"volatile" on variables and current processors Vir Campestris <vir.campestris@invalid.invalid> - 2019-08-19 21:56 +0100
Re: "volatile" on variables and current processors red floyd <dont.bother@its.invalid> - 2019-08-19 15:20 -0700
Re: "volatile" on variables and current processors red floyd <dont.bother@its.invalid> - 2019-08-19 15:21 -0700
Re: "volatile" on variables and current processors "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2019-08-19 16:37 -0700
Re: "volatile" on variables and current processors Vir Campestris <vir.campestris@invalid.invalid> - 2019-08-20 21:58 +0100
Re: "volatile" on variables and current processors scott@slp53.sl.home (Scott Lurndal) - 2019-08-20 22:18 +0000
Re: "volatile" on variables and current processors Vir Campestris <vir.campestris@invalid.invalid> - 2019-08-22 21:39 +0100
Re: "volatile" on variables and current processors Paavo Helde <myfirstname@osa.pri.ee> - 2019-08-21 09:02 +0300
Re: "volatile" on variables and current processors "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2019-08-20 23:10 -0700
Re: "volatile" on variables and current processors David Brown <david.brown@hesbynett.no> - 2019-08-21 08:34 +0200
Re: "volatile" on variables and current processors Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-08-21 20:39 +0100
Re: "volatile" on variables and current processors Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-08-21 21:02 +0100
Re: "volatile" on variables and current processors David Brown <david.brown@hesbynett.no> - 2019-08-22 13:30 +0200
Re: "volatile" on variables and current processors Bonita Montero <Bonita.Montero@gmail.com> - 2019-08-21 08:43 +0200
Re: "volatile" on variables and current processors "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-08-20 02:22 +0200
Re: "volatile" on variables and current processors David Brown <david.brown@hesbynett.no> - 2019-08-20 10:05 +0200
Re: "volatile" on variables and current processors Keith Thompson <kst-u@mib.org> - 2019-08-19 17:08 -0700
Re: "volatile" on variables and current processors Bonita Montero <Bonita.Montero@gmail.com> - 2019-08-20 06:08 +0200
Re: "volatile" on variables and current processors David Brown <david.brown@hesbynett.no> - 2019-08-20 10:14 +0200
Re: "volatile" on variables and current processors Juha Nieminen <nospam@thanks.invalid> - 2019-08-20 13:03 +0000
Re: "volatile" on variables and current processors David Brown <david.brown@hesbynett.no> - 2019-08-20 16:18 +0200
csiph-web