Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Roll Number :- 3
Subject :- Operating System
Semester :- BCA 4th sem
Assignment:-2
Question:-1
Discuss the Critical section problem and its solution
Answer
The critical section is a code segment where the shared variables can be accessed.
An atomic action is required in a critical section i.e. only one process can execute in
its critical section at a time. All the other processes have to wait to execute in their
critical sections.
A diagram that demonstrates the critical section is as follows −
In the above diagram, the entry section handles the entry into the critical section. It
acquires the resources needed for execution by the process. The exit section
handles the exit from the critical section. It releases the resources and also informs
the other processes that the critical section is free.
Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical
section at any time. If any other processes require the critical section, they
must wait until it is free.
Progress
Progress means that if a process is not using the critical section, then it
should not stop any other process from accessing it. In other words, any
process can enter a critical section if it is free.
Bounded Waiting
Bounded waiting means that each process must have a limited waiting time.
Itt should not wait endlessly to access the critical section.
Question:-2
Discuss in brief the problems of Process Synchronization (Bounded-Buffer Problem,
Readers–Writers Problem and Dining-Philosophers Problem)
Answer:
We present a number of synchronization problem as examples of large class of concurrency-
control problems. These problems are used for
do{
...
...
wait(empty);
wait(empty);
...
...
signal(mutex);
signal(full);
}while(TRUE);
1. Bounded-buffer Problem:
Bounded Buffer problem is also called producer consumer problem. This problem is
generalized in terms of the Producer-Consumer problem. Solution to this problem is,
creating two counting semaphores “full” and “empty” to keep track of the current number
of full and empty buffers respectively. Producers produce a product and consumers
consume the product, but both use of one of the containers each time.
Question:-3
Consider the following snapshot of a system in which five resources A, B, C, D and E are
Answer
Question:-4
Consider the following resource allocation graph.
Answer:-
1
Question:-5
Q 5 : Consider the following snapshot of a system in which four resources A,
B, C and D area available. The system contains a total of 6 instances of A, 4 of
resource B, 4 of resource C, 2 resource D.
a) Compute what each process might still request and fill this in under the
column Need.
b) Is the system in a safe state? Why or why not?
c) Is the system deadlocked? Why or why not?
d) If a request from P3 arrives for (2,1,0,0), can the request be granted
immediately?
Solution :
A)
STEP:-1
STEP:-2
P1’s Need = [0,1,0,2] ≤ Available = [8,4,5,3] (P1 satisfied)
STEP:-3
P2’s Need = [2,2,0,0] ≤ Available = [9,5,5,3] (P2 satisfied)
B)