Multiprocess Synchronization with a Single Semaphore?

Just initialize your semaphore at -4 if it's not a binary one.

– attwad Oct 26 '09 at 4:17 I didn't down vote you but I suspect it was because you can't initialize semaphores with negative values. In POSIX the value is unsigned and the Windows docs specifically state a value of 0 or greater. – Duck Oct 26 '09 at 5:13 this is quite limitative: I often need an inverse semaphore and I could never find one.

While not possible due to software limitations, his answer is perfectly logical. A bit of explanation would have been welcome though. – Adrien Plisson Oct 26 '09 at 6:37 It's a useful construct and if you search around you can find various implementations but I get the feeling there is no consensus on what the exact semantics should be.

– Duck Oct 26 '09 at 16:07 That's the solution I came up with... but as the other commenters (and my professor) have pointed out it's not allowed. – KidDaedalus Oct 26 '097 at 4:38.

You are a little light on the constraints imposed on your solution but see The Little Book of Semaphores and read through the sections on barriers. That should give you some ideas.

Thank you for the resource, that should be quite helpful. – KidDaedalus Oct 27 '09 at 4:40.

Turns out the professor had meant to say that you could use two semaphores instead of one. He believes, as I do after having thought about the problem for a while, that it is impossible to do with a single semaphore.

That's why I commented on your not mentioning much about constraints. You can do it with one semaphore and mutex protecting a counter but I wasn't sure if you could use mutexes or if they would count as a second semaphore. – Duck Oct 27 '09 at 5:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions