p46-kearns - A Correct and U n r e s t r i c t i v e I m p...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
A Correct and Unrestrictive Implementation of General Semaphores Phil Kearns 1 Department of Computer Science The College of William and Mary Williamsburg, Virginia 23185 1 Introduction Hemmendinger has recently presented a functionally correct implementation of general semaphores using only binary semaphores for concurrency control [2]. That work was motivated by a paper by Kotulski [3] in which the traditional textbook solution to the problem was shown to be incorrect. Hemmendinger's solution is presented in Figure 1. type semaphore -- record mutex = 1, delay = 0: binary_semaphore; count = 0: integer; end; Procedure P(var s:semaphore) begin PB(s.mutex); s.count := s.count - 1; if s.count < 0 then VB(s.mutex); PB(s.delay); end else VB(s.mutex) Procedure V(var s:semaphore); PB (s.mutex); s.count :-- s.count -4- 1; if s.count < 0 then VB(s.delay) Figure 1: Hemmindinger's Construction The important point to note in this code is that if one attempts to V a general semaphore whose value is less than or equal to zero, then the process calling V will not release mutual exclusion (i.e., it will not execute VB(s.mutex)) before its return from V. The retention of mutual exclusion is the mechanism by which the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

p46-kearns - A Correct and U n r e s t r i c t i v e I m p...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online