p7-hemmendinger - Comments on "A correct and unrestrictive...

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

View Full Document Right Arrow Icon
Comments on "A correct and unrestrictive implementation of general semaphores" David Hemmendinger Department of Computer Science and Engineering Wright State University Dayton, Ohio 45435 dhemm@ CS.wright.edu Kearns [4] offers an implementation of general semaphores from binary semaphores that he argues is better than the one I gave in [3], which I have since found in [1, pp. 56-57] and in [5]. First, he has misquoted my solution in his Figure 1 by adding a spurious else in the code for P, making it quite erroneous. Second, his proposed solution is incorrect. It restores the bug that my version eliminates and adds a new one as well. If two processes are in the midst of a P operation but have not actually suspended yet, his version permits two processes to execute V and do two VB's on an unlocked binary semaphore, with undefined result. Furthermore, Kearns uses a counter, s.wakecount to record the number of pending wakeup signals not yet consumed by the processes that are in the midst of executing P operations. However, since each increment of s.wakecount by a V does a VB(s.delay), and each pro- cess engaged in the P also does VB(s.delay) when s.wakecount > 0, if there are N suspended processes when N V's are done, there will be 2N-1 VB's executed. Both mistakes can be corrected by adding the italicized line to his code for V: Procedure V (var s : semaphore); begin PB(s.mutex); s.count := s.count + 1; if s.count < 0 then begin s.wakecount := s.wakecount + 1;
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.

This note was uploaded on 01/18/2012 for the course INFORMATIK 2011 taught by Professor Phanthuongcang during the Winter '11 term at Cornell University (Engineering School).

Page1 / 2

p7-hemmendinger - Comments on "A correct and unrestrictive...

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