Re:Mutexes and Semaphores Demystified
by Groxx on Sunday October 24, 2010 @09:29PM
(#1828016)
"As normally used" is part of the problem. How something is normally used has nothing to do with what it is.
General semaphores? I'll easily grant that would be difficult. Not impossible, but likely wasteful and a PITA.
Binary semaphores, which is where the debate lies? Store a whoDecremented thread pointer, cleared on increment. Which is functionally identical to Dekker's algorithm[1] and Eisenberg and McGuire's algorithm[2], except they require storage for all possible waiting threads, instead of the single storage of a semaphore.
General semaphores? I'll easily grant that would be difficult. Not impossible, but likely wasteful and a PITA.
Binary semaphores, which is where the debate lies? Store a whoDecremented thread pointer, cleared on increment. Which is functionally identical to Dekker's algorithm[1] and Eisenberg and McGuire's algorithm[2], except they require storage for all possible waiting threads, instead of the single storage of a semaphore.
edit: links: [1]: http://en.wikipedia.org/wiki/Dekker%27s_algorithm [2]: http://en.wikipedia.org/wiki/Eisenberg_McGuire_algorithm