3 Osy
3 Osy
Unit 4
2 MARKS
1) Define CPU and I/O burst cycle.
Ans:
CPU burst cycle: It is a time period when process is busy with CPU.
I/O burst cycle: It is a time period when process is busy in working
with I/O resources.
4 MARKS
1. .Describe I/O Burst and CPU Burst cycle with neat diagram. W-19
Ans :
CPU burst cycle: It is a time period when process is busy with CPU.
I/O burst cycle: It is a time period when process is busy in working
with I/O resources.
A process execution consists of a cycle of CPU execution and
I/O wait.
A process starts its execution when CPU is assigned to it, so
process execution begins with a CPU burst cycle.
This is followed by an I/O burst cycle when a process is busy
doing I/O operations.
A process switch frequently from CPU burst cycle to I/O burst cycle and
vice versa.
The complete execution of a process starts with CPU burst cycle,
followed by I/O burst cycle, then followed by another CPU burst
cycle, then followed by another I/O burst cycle and so on.
The final CPU burst cycle ends with a system request to terminate
execution.
2. Explain deadlock? What are necessary conditions for deadlock?
W-19
Ans:
In multiprogramming environment, several processes may compete for a finite
number of resources. A process requests resources and if the resources are not
available then the process enters into the waiting state. Sometimes a waiting
process is never again able to change its status because the resources requested
by it are held by other waiting processes. This situation is called as deadlock.
When a process request for resources held by another waiting process which in
turn is waiting for resources held by another waiting process and not a single
process can execute its task, then deadlock occurs in the system.
Example: Consider a system with three disk drives and three processes. When
each process request one disk drive, system allocates one disk drive to each
process. Now there is no more drive available in the system. If all three processes
request for one more disk drive, then all three processes will go into the waiting
state and system will go in deadlock state. Because any one process from the three
can execute only when one of them will release the disk drive allocated to it.
Necessary Conditions:
1. Mutual exclusion: At least one resource must be held in a non-sharable mode;
that is, only one process at a time can use the resource.
2. Hold and Wait: A process must be holding at least one resource and waiting to
acquire additional resources that are currently being held by other processes.
3. No pre-emption: Resources cannot be pre-empted i.e a resource can be released
only voluntarily by the process holding it.
4. Circular wait: A set {P0,P1…Pn} of waiting processes must exist such that P0
is waiting for a resource held by P1,P1 is waiting for a resource held by P2,…,Pn-
1 is waiting for a resource held by Pn and Pn is waiting for a resource held by P0.
Each process is waiting for the resources held by other waiting processes in
circular form.
Waiting Time
P1=17
P2=3
P3=0
P4=10
Average waiting time=Waiting time of all processes / Number of processes
=(17+3+0+10) /4
=30/4
=7.5 milliseconds (ms)
Gantt Chart FCFS
Waiting Time
P1=0
P2=9
P3=16
P4=19
Average waiting time=Waiting time of all processes / Number of processes
=(0+9+16+19) /4
=44/4
=11 milli seconds (ms)
Ans:
(i) Pre-emptive SJF: