Formal Aspects of Computing

, Volume 25, Issue 6, pp 947–969 | Cite as

Starvation-free mutual exclusion with semaphores

Open Access
Original Article

Abstract

The standard implementation of mutual exclusion by means of a semaphore allows starvation of processes. Between 1979 and 1986, three algorithms were proposed that preclude starvation. These algorithms use a special kind of semaphore. We model this so-called buffered semaphore rigorously and provide mechanized proofs of the algorithms. We prove that the algorithms are three implementations of one abstract algorithm in which every competing process is overtaken not more than once by any other process. We also consider a so-called polite semaphore, which is weaker than the buffered one and is strong enough for one of the three algorithms. Refinement techniques are used to compare the algorithms and the semaphores.

Keywords

semaphore binary semaphore mutual exclusion refinement starvation freedom 

References

  1. AdBO09.
    Apt KR, de Boer FS, Olderog E-R (2009) Verification of sequential and concurrent programs. Springer, New YorkCrossRefMATHGoogle Scholar
  2. AL91.
    Abadi M, Lamport L (1991) The existence of refinement mappings. Theor Comput Sci 82: 253–284MathSciNetCrossRefMATHGoogle Scholar
  3. And00.
    Andrews GR (2000) Foundations of multithreaded, parallel, and distributed programming. Addison Wesley, ReadingGoogle Scholar
  4. But97.
    Butenhof DR (1997) Programming with POSIX threads. Addison-WesleyGoogle Scholar
  5. CM88.
    Chandy KM, Misra J (1988) Parallel program design: a foundation. Addison-WesleyGoogle Scholar
  6. Dij65.
    Dijkstra EW (1965) Solution of a problem in concurrent programming control. Commun ACM 8:569Google Scholar
  7. Dij68a.
    Dijkstra EW (1968) Co-operating sequential processes. In: Genuys F (eds) Programming languages NATO Advanced Study Institute. Academic Press, London, pp 43–112Google Scholar
  8. Dij68b.
    Dijkstra EW (1968) The structure of the THE multiprogramming system. Commun ACM 11: 341–346CrossRefMATHGoogle Scholar
  9. Dij77.
    Dijkstra EW (1977) A strong P/V-implementation of conditional critical regions. Tech rept, Tech Univ Eindhoven, EWD 651. www.cs.utexas.edu/users/EWD
  10. Fra86.
    Francez N (1986) Fairness. SpringerGoogle Scholar
  11. Hes06.
    Hesselink WH (2006) Splitting forward simulations to cope with liveness. Acta Inf 42: 583–602MathSciNetCrossRefMATHGoogle Scholar
  12. Hes08.
    Hesselink WH (2008) Universal extensions to simulate specifications. Inf Comput 206: 108–128MathSciNetCrossRefMATHGoogle Scholar
  13. Hes11.
    Hesselink WH (2011) Starvation-free mutual exclusion with semaphores. http://www.cs.rug.nl/~wim/mechver/fairMXsema.html
  14. HHS86.
    He J, Hoare CAR, Sanders JW (1986) Data refinement refined. In: Robinet B, Wilhelm R (eds) ESOP 86. LNCS vol 213. Springer, New York, pp 187–196CrossRefGoogle Scholar
  15. Hoa74.
    Hoare CAR (1974) Monitors: an operating system structuring concept. Commun ACM 17: 549–557CrossRefMATHGoogle Scholar
  16. HS08.
    Herlihy M, Shavit N (2008) The art of multiprocessor programming. Morgan KaufmannGoogle Scholar
  17. Lam74.
    Lamport L (1974) A new solution of Dijkstra’s concurrent programming problem. Commun ACM 17: 453–455MathSciNetCrossRefMATHGoogle Scholar
  18. Lea00.
    Lea D (2000) Concurrent programming in Java. Addison-WesleyGoogle Scholar
  19. LH91.
    Lycklama EA, Hadzilacos V (1991) A first-come-first-served mutual-exclusion algorithm with small communication variables. ACM Trans Program Lang Syst 13: 558–576CrossRefGoogle Scholar
  20. LPS81.
    Lehmann D, Pnueli A, Stavi J (1981) Impartiality, justice and fairness: the ethics of concurrent termination. In: Proc 8th ICALP. LNCS, vol 115. Springer, Berlin, pp 264–277Google Scholar
  21. LV95.
    Lynch N, Vaandrager F (1995) Forward and backward simulations. Part I: untimed systems. Inf Comput 121: 214–233MathSciNetMATHGoogle Scholar
  22. MB85.
    Martin AJ, Burch JR (1985) Fair mutual exclusion with unfair P and V operations. Inf Process Lett 21: 97–100MathSciNetCrossRefMATHGoogle Scholar
  23. Mil71.
    Milner R (1971) An algebraic definition of simulation between programs. In: Proc 2nd int joint conf on artificial intelligence. British Comp Soc, pp 481–489Google Scholar
  24. Mor79.
    Morris JM (1979) A starvation-free solution to the mutual exclusion problem. Inf Process Lett 8: 76–80CrossRefMATHGoogle Scholar
  25. MvdS89.
    Martin AJ, van de Snepscheut JLA (1989) Design of synchronization algorithms. In: Broy M (eds) Constructive methods in computing science. Springer, Berlin, pp 445–478Google Scholar
  26. OG76.
    Owicki S, Gries D (1976) An axiomatic proof technique for parallel programs. Acta Inf 6: 319–340MathSciNetCrossRefMATHGoogle Scholar
  27. OSRSC01.
    Owre S, Shankar N, Rushby JM, Stringer-Calvert DWJ (2001) PVS version 2.4, system guide, prover guide, PVS language reference. http://pvs.csl.sri.com
  28. Sch08.
    Schellhorn G (2008) Completeness of ASM refinement. Electron Notes Theor Comput Sci 214: 25–49CrossRefGoogle Scholar
  29. Szy90.
    Szymanski BK (1990) Mutual exclusion revisited. In: Proceedings of the fifth Jerusalem conference on information technology. IEEE Computer Society, pp 110–117Google Scholar
  30. Tan08.
    Tanenbaum AS (2008) Modern operating systems, 3rd edn. Pearson Education/Prentice HallGoogle Scholar
  31. Udd86.
    Udding JT (1986) Absence of individual starvation using weak semaphores. Inf Process Lett 23: 159–162MathSciNetCrossRefGoogle Scholar

Copyright information

© The Author(s) 2011

Authors and Affiliations

  1. 1.Department of Computing ScienceUniversity of GroningenGroningenThe Netherlands

Personalised recommendations