Professional Documents
Culture Documents
Q1 : Five processes are competing for resources R0, R1, R2, and R3 where (R1, R2, R3, R4)
=(6, 4, 4, 2). The maximum claim of these processes and the initial resources allocated to these
processes, are given in the following space:
Solution:-
a) Does this initial allocation lead to a safe state? Explain with reason.
Ans;- Yes initial allocation is in safe state.
b) If P2 requests two instances of R1, one instance of R3, and one instance of R4, check
whether the system is still in safe state.
Ans:- No, resource exceed the maximum need,so there can be unsafe
sequence.
Q2 : A system consists of three processes P1, P2, and P3. There is a single resource type Printer
but with four instances. Each process declares the maximum resource demand of 3 instances. Is
deadlock possible in this situation?
Ans:- No deadlock is not possible in these case since there are 4 instance of
resources, and its need three instances for each process P1,P2,P3. There is
available instance , so deadlock is not possible in this case.
Q3 : There are four processes sharing a semaphore for synchronizing a shared variable. The
semaphore is guarding the CS of the processes where they update the shared variable. Initially,
the value of the semaphore is three. The actions taken by the processes in time sequence are
given below:
Show and explain the current and updated value of a semaphore at every time instant and the
processes in the wait queue.
Ans:- -
P operation also called as wait operation decrements the value of
semaphore variable by 1.
V operation also called as signal operation increments the value of
semaphore variable by 1.
At time T1,P1 is increment by 1
At time T2,P2 is increment by 2
At time T2,P3 is increment by 3
At time T3,P4 is increment by 4
Ans:- Synchronisation solution for the customers entering and leaving the
dining hall.
Let there be ten chair C1,C2,C3,C4,C5,C6,C,C8,C9,C10
wait( S )
{
while( S <= 0) ;
S--;
}
2. signal( S )
{
S++;
}
Let's modify the above code of the Dining chair Problem by using
semaphore operations wait and signal, the desired code looks like
void restaurant
{
while(1)
{
Wait( take_chairC[i] );
Wait( take_chairC[(i+1) % 10] ) ;
. .
. EATING dinner
.
Signal( put_chairC[i] );
Signal( put_chairC[ (i+1) % 10] ) ;
.
. THINKING
}
}
Q6: Consider a system with the following information. Determine whether the system is in a
deadlock situation.
Q7: Can there be a deadlock in the main memory?
Q8: Consider a system with the following information. Determine whether the system is in safe
state.
Total_Res
Ans:-
Q9: A buffer has 10 slots. The initial value of empty = 10 and full = 0. What will be the value of
empty and full in the following conditions?
( a) The producer has inserted five items and the consumer is not able to consume.
Ans:- empty = 5, full= 5
( b) The producer has inserted five more items and the consumer is not able to consume.
Ans:- empty = 0, full = 10
( c) The producer has produced three more items but cannot insert as the buffer is full.
Ans:- empty = 0, full = 10
void couples
{
while(1)
{
Wait( take_babyB[i] );
Wait( take_babyB[(i+1) % 3] ) ;
. .
.caretaking
.
Signal( put_babyB[i] );
Signal( put_babyB[ (i+1) % 3] ) ;
.
. T
}
}