Discussion:
Semaphore Queues FIFO?
(too old to reply)
Michail Turovskiy
2005-10-11 01:04:09 UTC
Permalink
For the semaphore queues, is there any restriction on them being FIFO?

When processes get added to a particular semaphore's wait queue, should
we preserve the order they came in so that the process that called P()
next will be the one that gets the semaphore? Or can we just pick the
process with the highest priority to get the semaphore, regardless of
the actual ordering?


Thanks,
m.t.
Iulian Neamtiu
2005-10-11 02:20:57 UTC
Permalink
Post by Michail Turovskiy
For the semaphore queues, is there any restriction on them being FIFO?
Well, FIFO is actually a requirement :) You don't have to
do anything, just using Wait and Wake_Up[_One] in the implementation
will take care of it, since Wait/Wake_up ensure a FIFO policy.
Priority does not matter at all, only ordering matters.


Iulian
Post by Michail Turovskiy
When processes get added to a particular semaphore's wait queue, should
we preserve the order they came in so that the process that called P()
next will be the one that gets the semaphore? Or can we just pick the
process with the highest priority to get the semaphore, regardless of
the actual ordering?
Thanks,
m.t.
Michael Hicks
2005-10-12 21:17:24 UTC
Permalink
Post by Iulian Neamtiu
Post by Michail Turovskiy
For the semaphore queues, is there any restriction on them being FIFO?
Well, FIFO is actually a requirement :) You don't have to
do anything, just using Wait and Wake_Up[_One] in the implementation
will take care of it, since Wait/Wake_up ensure a FIFO policy.
Priority does not matter at all, only ordering matters.
As a quick clarification: Wake_Up_One actually uses Find_Best, which
takes the first thread of those with the highest priority. However,
since only user processes will be on these queues, they all have the
same priority, so it boils down to FIFO.

-Dr. Hicks

Continue reading on narkive:
Loading...