Semaphores
Table of Contents
1 Semapahores
- Def: An ADT, with P, V operations on integers, and atomicity and await
- ./semaphoreSemantics.html
2 Split Binary Semaphores
2.1 Def
- Consider a binary semaphore b.
- Imagine "splitting" it into multiple binary semaphores such that
- sum-of b = {b1 + b2 + … + bn}, at all times
2.2 Uses
- Starvation-Free Mutex
- Passing the Baton Technique (cf. Readers-Writers)
3 Starvation-Free Mutex Semaphore
- The std solution is not starvation-free.
- Fairness: "Weak v Strong" semaphores.
- ./udding-morris-algs.html
- ./udding-david.html further commentary
4 Distributed Semaphores
- Implement semaphores in the distributed context: strictly peer-to-peer
- Where is "the" "queue" of processes waiting to finish P(m) located?
- Andrews Algorithm: ./semaphore-distributed.html
- Many "better" algorithms now exist.
- Most distributed implementations are "suspect".
5 The Power of semaphores
- Semaphore Ops: P and V.
- Will we improve the "power" of Semaphores with additional ops?
5.1 Add Peek and Pp?
- peek(s) defined as "return <s > 0>"
Pp(s) defined as
function Pp(s): boolean if <s > 0> -> <s := s - 1>; return True [] <s < 0> -> return False fi end
- Would either of the two ops add "power" to the semaphore?
5.2 Cigarette Smokers Problem
- What problems of concurrency can semaphores solve?
- Introduces an array of semaphores.
- Cigarette Smokers Problem cannot be solved without arrays.
- Cigarette Smokers Problem
6 References
- Allen B. Downey, The Little Book of Semaphores, book, 290+ pp, 2016. Free pdf, http://greenteapress.com/wp/semaphores/.
- Leslie Lamport, title = {The Mutual Exclusion Problem - Part I: A Theory of Interprocess Communication}, year = {2000} http://research.microsoft.com/users/lamport/pubs/mutual1.pdf
- author = {L. Lamport}, title = {The Mutual Exclusion Problem - Part II: Statement and Solutions}, year = {2000} http://research.microsoft.com/users/lamport/pubs/mutual2.pdf
- Vlad Popov and Oleg Mazonka, Faster Fair Solution for the Reader-Writer Problem, 2013. http://arxiv.org/pdf/1309.4507.pdf