694 views
1 votes
1 votes
Consider the following code:-
#define N 2
#define FALSE 0
#define TRUE 1
Int Interested [N];   //initially both are set to FALSE.
Void enter(int process)
{
       int other;
      Other=1-process;
      Interested[process]=TRUE;
      While(Interested[other]==TRUE);
            {
                 CRITICAL SECTION;
            }
}
Void Leave(int process)
{
          Interested[process]=FALSE;
}
Find whether progress, mutual exclusion and bounded waiting are satisfied?

1 Answer

0 votes
0 votes

I think,  mutual exclusion is satisfied and bounded waiting is also there. 

Mutual exclusion is there because only one process can get in CS at a time.

And bounded waiting satisfies here because, if process P1 enters into CS and when it comes out making its own flag false, then either other interested process P2 will get CS or the system will go in deadlock condition, but P1 will not get into CS before P2( if P2 was interested earlier).


Condition for deadlock - 

when one process P1 executes line - 

 Interested[process]=TRUE;

and  got preempted for some time.

Now if other process P2 comes and executes the line,

 Interested[process]=TRUE;

now both will be waiting for each other for infinite time and are in deadlock ..

Related questions

0 votes
0 votes
2 answers
1
shivajikobardan asked Jul 22, 2023
795 views
Sorry if this is a stupid question. But it really intrigued me. Same resources at different algorithms are telling different ways to test these stuffs.Here's an algorith...
0 votes
0 votes
1 answer
3