views:

73

answers:

1

Are semaphores released FIFO, random, or using some other algorithm? Does the algorithm avoid starvation?

+1  A: 

This article says you cannot assume FIFO, though seems to slightly imply that FIFO is what is generally expected. I might be overstating that, though.

This article confirms that they are not guaranteed to be released in any order:

Semaphores in C# are not First in First Out, the implementation actually does not guarantee the order in which tasks are released.

Michael Haren
Do you know if the algorithm is designed to avoid starvation?
Orion Adrian
I would guess that starvation is unlikely but not guaranteed. Just a guess, though.
Michael Haren