Operating System L 4
Operating System L 4
Dr.Sohail Saif
Assistant Professor
Department of Computer Applications
Maulana Abul Kalam Azad University of Technology, West Bengal
Process Synchronization
Process Synchronization is the coordination of execution of multiple
processes in a multi-process system to ensure that they access shared
resources in a controlled and predictable manner. It aims to resolve the
problem of race conditions and other synchronization issues in a
concurrent system.
The task of the Producer is to produce the item, put it into the memory
buffer, and again start producing items. Whereas the task of the
Consumer is to consume the item from the memory buffer.
Let's understand what is the problem?
Below are a few points that considered as the problems occur in Producer-
Consumer:
The producer should produce data only when the buffer is not full. In
case it is found that the buffer is full, the producer is not allowed to store
any data into the memory buffer.
Data can only be consumed by the consumer if and only if the memory
buffer is not empty. In case it is found that the buffer is empty, the
consumer is not allowed to use any data from the memory buffer.
The process of using Semaphores provides two operations: wait (P) and signal
(V).
The wait operation decrements the value of the semaphore, and the signal
operation increments the value of the semaphore
Semaphores are used to implement critical sections, which are regions of code
that must be executed by only one process at a time
Binary Semaphore
This is also known as a mutex lock. It can have only two values – 0 and 1. Its
value is initialized to 1. It is used to implement the solution of critical section
problems with multiple processes.
P0 P1
wait(S); wait(Q);
wait(Q); wait(S);
. .
. .
. .
signal(S); signal(Q);
signal(Q); signal(s);