Process Synchronization
Process synchronization is the task of coordinating the execution of processes in such a way that no two processes can access the same shared data and resources.
For an example of a bank account that has a current balance of 500 and there are two users which have access to that account, User 1 and User 2 both are trying to access the balance.
If Process 1 is for withdrawal and Process 2 is for checking the balance both will occur at the same time, then User 1 might get the wrong current balance.
Process synchronization is to avoid this kind of data inconsistency.
|
|
|
One method of process synchronization is to provide
mutual exclusion.
By mutual exclusion, we mean that if one process is executing inside critical section, then the other process must not enter in the critical section.
Critical section is the part of a program which tries to access shared resources.
That resource may be any resource in a computer like a memory location, data structure, CPU or any IO device.
Progress means that if one process doesn’t need to execute into critical section, then it should not stop other processes to get into the critical section.