Process Synchronization
A cooperating process can be affected by other processes executing in the system.
When several processes access the same data concurrently and the outcome of the execution depends on the particular order in which access takes place is called race condition.
If a process is executing in its critical section, then no other processes can be executed in their critical section. This condition is called Mutual Exclusion.
Semaphore is a synchronization tool. Semaphore is a mechanism which synchronizes or controls access of threads on critical resources. There are two types of semaphores i) Binary Semaphore ii) Counting Semaphore.
A semaphore is a shared integer variable that can not drop below zero. In binary semaphore, if the value of the semaphore variable is zero that means there is a process that uses a critical resource and no other process can access the same critical resource until it is released.
Mutual exclusion can be provided by both mutex locks and binary semaphore. Mutex is a short form of Mutual Exclusion. Binary semaphore also provides a mechanism for mutual exclusion. Binary semaphore behaves similar to mutex locks.
When a high priority task is indirectly preempted by a medium priority task effectively inverting the relative priority of the two tasks, the scenario is called priority inversion.
Process synchronization can be done on both hardware and software level. Critical section problems can be resolved using hardware synchronisation. But this method is not simple for implementation so software synchronization is mostly used.
A monitor is a module that encapsulates shared data structures, procedures that operate on shared data structure, synchronization between concurrent procedure invocation.
Comments
Post a Comment