Mohammad Saddam Mashuri's OS202
Process Synchronization
Like I usually say, fundamentals are important. We first need to understand why do we need to synchronize processes and such. Process Synchronization is the activity of coordinating the execution of processes such that no two processes can have access to the same shared data and resources. Synchronizing processes are important as when several threads share data, changes made by one process may override changes made by another process running parallel, which results in inconsistent data. Process synchronization prevents this.
Semaphores
Very important for understanding how to solve the assignment. A semaphore is an object with an integer value that we can manipulate with two routines; in the POSIX standard, these routines are sem_wait() and sem_post(). sem_wait() will decrement the value of the semaphore, while sem_post() increments the value of the semaphore.
Deadlocks
Deadlocks may happen when a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. Deadlocks occurs if and only if, Mutual Exclusion, Hold and Wait, No preemption, and Circular Wait occurs. This is discussed in the next next point.
Deadlock Avoidance: Banker’s Algorithm
Although deadlocks can be prevented, they do have side effects. Thankfully, we can avoid deadlocks by using the Banker’s algorithm. Banker’s Algorithm is resource allocation and deadlock avoidance algorithm which test all the request made by processes for resources, it checks for the safe state, if after granting request system remains in the safe state it allows the request and if there is no safe state it doesn’t allow the request made by the process.
The Critical-Section Problem: Peterson’s Solution, supports point no. 2
A quick note. I should put this higher, but I can’t help but think that deadlocks are also crucial to understand the synchronization problem and this sub-topic is quite complicated, which results in a lower rank. It is recommended that you read the book to understand this completely. Nevertheless this sub-topic supports point no. 2 which boosts how important this sub-topic is.
Alright, back to it. Each process in a system has a segment of code, called a critical section, in which the process may be accessing and updating data that is shared with at least on other processes. The critical-section problem is to design a protocol that the processes can use to synchronize their activity so as to cooperatively share data. A classic software-based solution to the critical-solution problem known as Peterson’s solution. Peterson’s solution provides a good algorithmic description of solving the critical-section problem and illustrates some of the complexities involved in designing software that addresses the requirements of mutual exclusion, progress, and bounded waiting.
Monitors
This is deprecated, but nonetheless it is still important. A monitor is a synchronization construct that allows threads to have mutual exclusion among the processes. In simpler words, monitors helps in controlling shared data access.
Sources:
Abraham Silberschatz - Operating System Concepts -Wiley (2018)
http://pages.cs.wisc.edu/~remzi/OSTEP/
https://www.javatpoint.com/os-process-synchronization-introduction
https://prepinsta.com/operating-systems/process-synchronization/
https://www.tutorialandexample.com/monitors-in-operating-system/
https://tutorialspoint.dev/computer-science/operating-systems/deadlock-prevention
https://www.geeksforgeeks.org/deadlock-detection-recovery/