Hello Friends, In this blog post(Critical Section Problem With a Simple Example) we are going to discuss the critical section problem that you have read about on the subject of the operating system.
A critical section is part of a program that constantly tries to access shared resources. These resources could be anything related to the computer like memory allocation, CPU, data structure, and input and output devices.|Critical Section Problem With a Simple Example|
It has been observed that most of the users get confused with this critical section problem specially the students who study this in their academic syllabus.|Critical Section Problem With a Simple Example|
But you don’t have to worry at all as in this blog post we are going to explain this critical section problem as simply as possible with a simple example.
A critical section is a part of the program where only one process can be executed at one time.
And until it finishes the execution no other process can enter into the critical section.
Till then the other process has to wait for their chance.
It is really hard for the operating system to allow and disallow any process to enter into the critical section.
But still, it manages the best synchronization between the processes and gets them executed in the critical section.
So we use this critical section problem to design a set of protocols where the processes do get mashup into the race or deadlock condition.
The main task or focus that we have through process synchronization is to solve the problem of the critical section.
And to do the same we have to satisfy a few important conditions which are given below:
Requirements for condition satisfaction :
mutual exclusion :
Our solution must provide mutual exclusion.
As per the mutual exclusion if any process is executed in the critical section then no other process can enter into the critical section until the process execution is finished.
Progress :
If any process does not need the critical section for execution then it can not stop the other process from entering into the critical section.
Secondary:
Bounded waiting :
We should be capable of predetermining the waiting time of a process to enter into the critical section.
It should happen that any process is waiting endlessly to enter the critical section.
Architectural Neutrality
If our critical section problem solution is working fine at one architecture then it should work fine at the other architecture too.
Example: Critical Section Problem With a Simple Example
To understand this critical section problem better we make understand you with the help of a simple example:
Suppose we have a variable X and process A wants to read this and process B wants to write it at the same time.
But if this happens then it might be a case that Process A gets the wrong value to write and it would be the updated value that B will update through the write operation.
So to solve this problem we first execute process B into the critical section and let it allow us to update or write the value of X.
And till then process A will wait to read the value of X.
Once process B finishes the execution and updates the value of X then process A will execute into the critical section and…
…will read the value of X, and this time process B can not update the value of X as it can not enter into the critical section.
So doing this way process A will read the correct and updated value of X.|Critical Section Problem With a Simple Example|
Click here if you want to explore the Critical Section Problem In Hindi…
You can also go through a few more amazing blog links below related to operating systems:
disk scheduling क्या होती है…
FAT32 Advantages and Disadvantages…
Overlay advantages and disadvantages in programs…
What is the use of Cache Memory…
What is Linker? Why is it required?…
types Of File Operations…
What are the file Organisation and its types…
Dijkstra: Bankers Algorithm For Deadlock Avoidance…
What is a thread in the operating system with an example…
Cache Memory In Hindi…
Linker In Hindi…
What Are Multithreading Models in Hindi…
Dynamic Storage Problem In OS In Hindi…
Process states in the Operating system in Hindi…
FAT32 Advantages And Disadvantages In Hindi…
Critical Section Problem With a Simple Example…
Critical Section Problem In OS In Hindi…
Dijkstra Algorithm In Hindi|Banker’s Algorithm In Hindi…
What Is Dynamic Storage Problem…
What are the Fork and Exec system calls…
Multithreaded Process: Benefits & Models…
The Process States In Operating System…
Conclusion:
So friends, In this blog post(Critical Section Problem With a Simple Example) we have gone through the critical section problem. In the problem of the critical section, one process executes into the critical section at a time, and till then no other process can enter the critical section. If any process does not need to enter into the critical section then it can not stop the other process from entering into the critical section. This critical section helps to retrieve the correct and updated value of the program.
In the case of any queries, you can write to us at support@a5theory.com we will get back to you ASAP.
Hope! you would have enjoyed this post about Critical Section Problem With a Simple Example.
Please feel free to give your important feedback in the comment section below.
Have a great time!