Professional Documents
Culture Documents
20/05/2021 1
Type of Process
• Two processes are said to be independent if the execution of one process does not
affect the execution of another process.
• Cooperative Processes
• Two processes are said to be cooperative if the execution of one process affects the
execution of another process.
• These processes need to be synchronized so that the order of execution can be
guaranteed and consistent.
20/05/2021 2
Why Synchronization
• Need of Synchronization
20/05/2021 3
Race Condition
• When more than one processes are executing the same code or accessing the
same memory or any shared variable in that condition there is a possibility that
the output or the value of the shared variable is wrong so for that all the
processes doing the race to say that my output is correct this condition known as
a race condition.
20/05/2021 4
Critical Section
20/05/2021 5
20/05/2021 6
Requirements of Synchronization mechanisms
• Mutual Exclusion: If a process is in the critical section, then other processes shouldn't be
allowed to enter into the critical section at that time.
• Bounded Waiting: There must be some limit to the number of times a process can go into the
critical section i.e. there must be some upper bound.
• If no upper bound is there then the same process will be allowed to go into the critical section
again and again and other processes will never get a chance to get into the critical section.
20/05/2021 7
Synchronization Mechanism
• Lock Variable
• TSL (Test-Set-Lock)
• Turn Variable
• Interested Variable
• Peterson Solution
• Semaphore
20/05/2021 8
Lock Variable
20/05/2021 9