602 views
1 votes
1 votes
What is actually a problem with critical section.....please explain..

1 Answer

1 votes
1 votes
critical section is the part of the program where shared resources are accessed by the processes.

for example consider 2 processes and they are sharing 1 variable

p1

process1

{

       non critical section

       critical section

    non critical section

}

process2

{

      non critical section

     critical section

     non critical section

}

now,

     if a process enters into critical section in 1st program and it gets preempted and at the same time another process wants to enter in critical section then a problem occurs and that is called race around condition.

i.e, out put of a process depends on order of execution instructions of a process

to solve this problem we insert a piece of code before the critical section called entry section

and to insert another piece of code after critical section called exit section

by doing this we can avoid race around condition i.e, only 1 process enter in critical section and after completion of that process then only next process get into critical section

Related questions

0 votes
0 votes
1 answer
1
N3314nch41 asked Sep 10, 2023
359 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??