21cs56 - Operating Systems Chapter 6 - (Module2) Process Synchronization
21cs56 - Operating Systems Chapter 6 - (Module2) Process Synchronization
21cs56 - Operating Systems Chapter 6 - (Module2) Process Synchronization
Chapter 6- (Module2)
PROCESS SYNCHRONIZATION
while (true) {
while (count == 0)
; // do nothing
nextConsumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
count--;
/* consume the item in nextConsumed
}
3.Bounded Waiting - A bound must exist on the number of times that other
processes are allowed to enter their critical sections after a process has made
a request to enter its critical section and before that request is granted.
⚫ Assume that each process executes at a nonzero speed
⚫ No assumption concerning relative speed of the N processes
Department of Information Science and Engg 14
Transform Here
Two general approaches are used to handle critical sections in
operating systems:
1. preemptive kernels A preemptive kernel allows a process to be
preempted while it is running in kernel mode.
2. nonpreemptive kernels A nonpreemptive kernel does not allow a
process running in kernel mode to be preempted.
• A kernel-mode process will run until it exits kernel mode,
blocks, or voluntarily yields control of the CPU.
• So is free from race condition.
Dining-Philosophers Problem
P2 1 3 3
P3 2 1 4
P4 3 5 5
P5 4 2 5