Beruflich Dokumente
Kultur Dokumente
CONTENTS
• Definition
• Process State
• Scheduler
• Arbitrary Interleaving
• Context Switch
• Synchronization Constructs
• Blocked Process
• Possible state diagram
• Conclusion states
• General Vs Binary semaphore.
CONTENTS
• semaphore S (k, Ф)
• There are two atomic operations defined on a semaphore S
(where p denotes the process that is executing the statement):
GENERAL SEMAPHORE
VS BINARY SEMAPHORE.
• A semaphore whose integer component can take arbitrary
non-negative values is called a general semaphore.
• A semaphore whose integer component takes only the
values 0 and 1 is called a binary semaphore.
• A binary semaphore is initialized with (0,Ф) or (1, Ф). The
wait(S) instruction is unchanged, but signal(S) is now
defined by:
GENERAL VS BINARY
THE CRITICAL SECTION PROBLEM
FOR TWO PROCESSES
CRITICAL SECTION WITH SEMAPHORES
(TWO PROC., ABBREV.)
STATE DIAGRAM
FOR THE SEMAPHORE SOLUTION
CORRECTNESS
semaphore S1 ← 0, S2 ← 0
p q r
p q
• Strong Semaphores.
• Busy-Wait Semaphores.
STRONG SEMAPHORES
• A busy-wait semaphore
does not have a
component S.L, so we will
identify S with S.V.
• The operations are
defined as follows:
WITH BUSY-WAIT SEMAPHORES
YOU CANNOT ENSURE THAT A PROCESS
ENTERS ITS CRITICAL SECTION
BUSY-WAIT SEMAPHORE USAGE
Deadlock in the case that all philosophers picked their left fork … none
of them will find its right fork.
SECOND ATTEMPT