Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <0385d20b-a476-4b85-bfa7-de533543a076@googlegroups.com> (permalink) |
|---|---|
| Newsgroups | comp.std.c++ |
| From | Jason McKesson <jmckesson@googlemail.com> |
| Subject | Re: semantics of multithreading? |
| Organization | unknown |
| References | <b5950868-7d0a-4485-8c1e-166e74843669@googlegroups.com> <0deed2c4-9e51-406b-b608-68c4915dde3d@googlegroups.com> <80e6c857-659f-4b79-87a4-67419d665eed@googlegroups.com> |
| Date | 2013-06-16 19:58 -0600 |
On Saturday, June 15, 2013 6:50:03 AM UTC-7, sieg...@googlemail.com wrote:
> On Thursday, June 13, 2013 11:42:34 AM UTC-4, Martin Bonner wrote:
>
> > On Monday, June 10, 2013 8:23:21 PM UTC+1, sieg...@googlemail.com wrote:
>
> > > I am suspicious of the latter case because it could allow the
>
> > > compiler to introduce a deadlock or livelock in some programs.
>
> >
>
> > I don't see how. The compiler can optimize in a way that eliminates
>
> > certain possible orderings, but if there is a deadlock in the ordering
>
> > it chooses then that can happen anyway.
>
>
>
> Example:
>
>
>
> void f1() { while x.load() {}; }
>
> void f2() { x.store(0); }
>
> x.store(1);
>
> p1 = fork(f1);
>
> p2 = fork(f2);
>
> p1.start(); p2.start();
>
> p1.join(); p2.join();
>
>
>
> I would argue that the above program can terminate -- it is not livelocked.
You can argue whatever you like; the standard doesn't agree.
The standard is very clear on this; you may not *assume* that a thread
will ever execute past a certain point unless you use an explicit
ordering primitive like a thread ::join or a mutex.
Will this ever deadlock in real systems? Probably not. Does the
*standard* guarantee that it won't? Absolutely not.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
semantics of multithreading? siegebell@googlemail.com - 2013-06-10 12:23 -0700
Re: semantics of multithreading? Jason McKesson <jmckesson@googlemail.com> - 2013-06-11 12:19 -0700
Re: semantics of multithreading? Martin Bonner <martinfrompi@yahoo.co.uk> - 2013-06-13 08:42 -0700
Re: semantics of multithreading? siegebell@googlemail.com - 2013-06-15 08:42 -0600
Re: semantics of multithreading? Jason McKesson <jmckesson@googlemail.com> - 2013-06-16 19:58 -0600
Re: semantics of multithreading? usenet@mkarcher.dialup.fu-berlin.de (Michael Karcher) - 2013-06-18 11:36 -0700
Re: semantics of multithreading? siegebell@googlemail.com - 2013-06-23 19:19 -0600
Re: semantics of multithreading? siegebell@googlemail.com - 2013-06-23 19:18 -0600
csiph-web