How operating systems enable processes to share and exchange information

 

A critical section is the part of the process where the code for accessing the shared resources is written. The critical section problem refers to a solution which allows the processes to cooperate when they share common resources. In order for this to happen, a process must take care of three properties: mutual exclusion, progress, and bounded wait.

  •         Mutual Exclusion: Only one process can execute its critical section at a time.
  •          Progress: If a process doesn’t want to enter in its critical section, it should not be permitted to block another process from entering
  •          Bounded Waiting: Bounded time up to which the process has to wait to enter its critical section after making the request. Ensures every process requesting to enter its critical section get the chance within the finite amount of time.

 A software-based solution to critical section problem discussed in our text is known as Peterson’s solution. Peterson’s Algorithm is used to synchronize two processes using two variables, a bool array flag of size 2 and an int variable turn. When a process wants to execute its critical section, it sets its flag to true and the variable turn as the index of the other process, allowing the other process to run first. The process waits until the other process has finished its own critical section, then enter its critical section and adds or removes a random number from the shared buffer. After completing the critical section, the flag is set to false, indicating it does not wish to execute anymore.



References

GeeksforGeeks (2019, Oct 28). Peterson's Alogorithm in Process Synchronization. Retrieved from https://www.geeksforgeeks.org/petersons-algorithm-in-process-synchronization/ (Links to an external site.)

Silberschatz, A., Galvin, P. B., & Gagne, G. (2014). Operating system concepts essentials (2nd ed.). Retrieved from https://redshelf.com/




Comments

Popular posts from this blog

How main and virtual memory solve memory management issues

Files, mass storage, and I/O in a modern computer system