Docstoc

semaphore

Document Sample
semaphore Powered By Docstoc
					      The operators P and V
• P (request)
  – P (sem)
       – Sem - -
       – If Sem < 0
            » Block on Sem


  – V (sem)
       – Sem ++
       – If Sem < =0
            » Wake up next process
      Types of Semaphores
• Binary semaphore – maximum value of 1



• Counting semaphore – maximum value
  other than 1
  Producer/Consumer Problem
• Set of 10 buffers
• Producer – fills a buffer with information
• Consumer – empties the buffer when it is
  full
    Producer/Consumer Problem
•   Producer     •   Consumer
•   P (empty)    •   P (full)
•   P (mutex)    •   P (mutex)
•   <CS>         •   <CS>
•   V (mutex)    •   V (mutex)
•   V (full)     •   V (empty)

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:20
posted:11/6/2011
language:English
pages:4