1,410 views
0 0 votes

2 Answers

Best answer
6 6 votes

Available resources : $(x,y,z) = (3,3,2)$, So, We can satisfy demand of $P_{1}$ and $P_{3}$ initially. So, Take both of these cases and finally add the safe sequences we get from these two cases:

Starting with $P_{1}$, needs can be satisfied like :

And starting with $P_{3}$ as

So, Safe sequences possible $\color{olive}{= 6 + 2 + 6 + 2 = 16}$

PS:) The only thing to note here is that once the resource availability is sufficient enought to satisfy every need we find all arrangements of remaining requests. like ($3! = 6$ ways) in above case.

• selected by
1 1 vote

The key point to be followed in solving this type of question is :

We select a process such that its need (demand) is satisfied by the currently available resources.

For this question hence we need to calculate the need matrix first which is given by :

Need[i][j] = Maximum[i][j] - Allocation[i][j]    .So need matrix is given by :

 A         B        C

 7        4         3

 1        2         2

 6        0         0

 0        1         1

 4        3         1

Having calculated the need matrix in order to find no of safe sequences , we need to do it carefully as by partly taking cases and partly applying combinatorics keeping in mind the requirements of safety algorithm.

We have to select a process such that the need of every resource of that process <= the available resource at that instant

So initially we have only P1 and P3 satisfying the given constraint.Hence we solve them separately :

Case 1(P3 is selected first) :

Now if P3 is selected first , then available is updated as :

available[j]  =   available[j] + allocation[3][j] where j varies from 1 to 3 since after usage a process needs to free its allocated resources , hence we are adding it to the available number of resources of each type.

So available =  [3   3    2]  +   [2    1     1]     =    [ 5     4      3]

Now considering the condition need[i][j] <=  available[j] for the next process to be selected , we have only 2 such process after P3 i.e.  P1     and      P4

Proceeding with P1 , meaning let P1 is selected after P3 , so available is now updated as :

 [5    4     3] +   [2    0    0]     =    [7   4    3]

Now we can see that we do not need to proceed further since the need of any of the 3 remaining will be satisfied from this point.At this point any of the 3 processes can be selected , after 3rd process is executed the available resources will further increase , so not a problem.

Hence no of ways from this instant if we take P1 after P3 = 3!  =   6

If we consider choosing P4 after P3 , then after updation of available resources , only P1 satisfies so P1 has to be selected and after P1 , either P0 or P2 can come.

So no of ways  here =  2 

Hence , for a) part i.e. beginning with P3  , no of safe sequences =   6 + 2  = 8

For part b) also i.e. safe sequence beginning with P1 , we will have 6 cases if we have P3 after P1 and 2 cases if we have P4 after P1 .

So no of sequences  here = 8 as well

Hence total no of safe sequences   =    8 + 8

                                                      = 16

Hence 16 is the correct answer.

Position:
Show:

Related questions

1 1 vote
2 2 answers
715
715 views
js__ asked Apr 18, 2025
715 views
How to draw the tree diagram for these types of questions fork() calls ?1.main() { if( fork() ) { if(!fork()) { fork(); printf(" 1 "); } else { fork(); printf(" 2 "); } }...
0 0 votes
1 1 answer
1.1k
1.1k views
Light Yagami Ryuk asked Sep 8, 2024
1,082 views
Consider the process information for set of processes, assuming the context switch delay to be 0, calculate the average waiting time, average turnaround, average response...
0 0 votes
0 0 answers
308
308 views
mr.smooth asked Jun 12, 2024
308 views
Consider a process P in xv6 that invokes the wait system call. Which of the following statements is/are true? If P does not have any zombie children, then the wait system...
1 1 vote
1 answers 1 answer
3.6k
3.6k views
Syntax-error asked Mar 13, 2023
3,642 views
Consider arrival time and execution time for the following process:-P.id A.T B.T1 2 52 7 93 8 34 10 4 Ass...