On Tue, 11 Sep 2012 01:32:59 +0200, andy pugh wrote: > On 10 September 2012 20:29, EBo <[email protected]> wrote: >> I do not think will work. Your blocking flag needs to be read and >> set >> with an atomic operation (ie. single instruction). > > Why isn't a block atomic in the context?
Did you intend your read/set to be atomic? If so then you and I are on the same page. If not then I was just trying to make a point. From your reaction it seems that you already know what I meant and it is just a point of us agreeing that it needs to me there and I did not understand that your read honored the necessity. Other than that, reading a value does not modify the value in an atomic operation so that the next one does not slip through. Let me see if I cam make this any sense... thread #1 thread #2 wait until flag1 unset some instruction... some instruction... wait until flag1 unset set flag1 some instruction... some other instruction... set flag1 now both threads are in the critical region if the the thread context switch happens in the wrong place. I'm assuming at this point that we are both agreed that this is a bad idea, but the sublty is in how either of us pseudo-coded the problem. Now addressing a separate issue of "block[ing] atomic" operations. There are times you want blocking and/or non-blocking operations. My wait was intended to be blocking (ie not unblocked). But that is besides the point. Can we agree that atomicity of lock/semaphore/mutex is useful/necessary here? EBo -- ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
