The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
80 views

Consider  the two processes need to access $P_{i}$ and $P_{j}$ need to access the C.S. The following synchronization construct used by both the processes.

Process Pi

While(true){
    j=false;
    i=true;
    while(j==true);
    CRITICAL SECTION
    i=false;
}

 

Process Pj

While(true){
    i=false;
    j=true;
    while(i==true);
    CRITICAL SECTION
    j=false;
}

I got it is not satisfying M.E., but will it satisfying deadlock too??

Plz explain-

asked in Operating System by Veteran (112k points) | 80 views
+1

Yes, but that should be spinlock actually.

say after execution of Pi 's

While(true)

{

j=false;


the process Pi is preempted, and Pj gets the turn.
Now say Pj after executing -->

While(true){

i=false;

j=true;


gets preempted and the control goes back to Pi, now Pi executes --> i=true;

Now see that both the while conditions of both the processes are satisfied. So they will be in a spinlock.

+1
 j=false; // in Pi then Context switch to Pj
 i=false; // in Pj then Context switch to Pi
 i=true; // in Pi then Context switch to Pj
 j=true; //in Pj then Context switch to Pi
while(j==true); // in Pi then Context switch to Pj (stuck in loop)
while(i==true); //since i is true it also gets stuck in loop

hence there is deadlock.

+1
I think spinlock actually..becuase deadlock means everything should Halt, but in spinlock we are continuously checking whether our required condition is satisfied or not. And here also we are running continously in a while loop. So spin lock must be the appropriate answer.
0
not livelock

right??
0
Got no idea what a Livelock is..
+1

@Hirak @Satbir

why r u telling spinlock??

Spinlock means one process already in C.S. and other pricess spins before lock. But deadlock means no work can process there. Right??

Chk  livelock here https://gateoverflow.in/156236/livelock-and-spinlock πŸ˜€

+1

In concurrent computing, a deadlock is a state in which each member of a group of actions, is waiting for some other member to release a lock.

so its deadlock.


A livelock is similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, none progressing.

here the states of the process are not changing so it is not livelock.

https://en.wikipedia.org/wiki/Deadlock


If you notice that in this question there are 2 spinlocks and

Attempting to acquire a second spin lock while holding another spin lock also can cause deadlocks.

so here it is deadlock not spinlock.

read the last paragraph.

https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/preventing-errors-and-deadlocks-while-using-spin-locks#nested-spin-lock-acquisitions

0

yes, it should be Deadlock. Turns out my concept was not clear on spinlock. Thanks @srestha    and @Satbir

2 Answers

0 votes

Solution:-

answered by (77 points)
0 votes

Dead lock is present

answered by Boss (33.9k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,588 questions
54,198 answers
187,539 comments
71,152 users