193 views
0 votes
0 votes
Consider the four mutex locks L1, L2, L3, and L4. Two processes A and B request these four locks. Each process requests them in some (possibly different) pre programmed sequence. There are 24 possible sequences for requesting the locks making for 576 programming possibilities. How many of these can possibly result in a deadlock?

1 Answer

0 votes
0 votes

Approach: Trying this by negative approach, where we'll first count all the ways we can avoid deadlock and the subtract it from total cases.

Now, consider this scenario.
 

Process A
L1
X
X
X

 

 

Process B
L1
X
X
X

Note: X here means "don't care"

This is one of the instance of cases where deadlocks are avoided. This happens when, both the processes ensure that the first lock they have requested is the same one, as long as this is true, there will be no deadlock.
So this can be done in 4*3!*3! ways. How? For both the processes, first lock must be same henceforth. there are 4 ways to choose the first lock (L1,L2,L3,L4). Then the 3 remaining slots in both processes, can be filled by any permutation of the remaining 3 locks which gives the factor of 3!*3!.
Now, 4*3!*3! = 144.
and 576 - 144 = 432.
432 should be the answer.

 

 

edited by

Related questions

171
views
1 answers
0 votes
jugnu1337 asked May 12
171 views
Barrier is a synchronization construct where a set of processes synchronizes globally i.e., each process in the set arrives at the barrier and waits for all others ... n. (d) The barrier implementation is correct for the set of n processes
373
views
1 answers
0 votes
Prince Sindhiya asked Jan 6, 2019
373 views
Consider a paged virtual memory system with 32-bit virtual addresses and 1K-byte pages. Each page table entry requires 32 bits. It is desired to limit the page table size to one ... , 32987 2. 16,641, 65,973 3.64, 256 4.4161, 16494
638
views
0 answers
1 votes
Prince Sindhiya asked Dec 16, 2018
638 views
ANSWER GIVEN IS A)IN THESE QUESTION I GOT THAT IT WILL NOT SATISFIED ME AND BOUNDED WAIT BUT HOW PROGRESS IS SATISFIED I AM NOT GETTINGWHAT I UNDERSTOOD ... PROGRESS CAN BE SATISFIED PLEASE CLEAR THIS POINT AND TELL ME HOW TO APPROACH HERE
3.0k
views
1 answers
3 votes
Arjun asked Feb 16
2,976 views
Consider a multi-threaded program with two threads $\mathrm{T} 1$ and $\mathrm{T} 2$. The threads share two semaphores: $s1$ (initialized to $1$ ... $1, \mathrm{~T} 1$ does not print anything (deadlock)