in Operating System
3,091 views
3 votes
3 votes
A and B are the only two processes in the system. Both are in the ready state. A arrives before B but the difference in arrival time is negligible. A is a CPU bound process while B is a I/O bound process. The pseudocode for A and B are as follows:
A:
repeat 2 times:
compute (takes 4 unit time)
write result to disk (takes 1 unit time)
exit (takes negligible time)
 
B:
repeat 2 times:
compute (takes 2 unit time)
write result to disk (takes 4 unit time)
exit (takes negligible time)
 
Assume that
(i) I/O can be done concurrently, i.e., the time taken to write to disk will not be prolonged if both processes write to disk at the same time;
(ii) the running time of A and B can be estimated accurately;
(iii) time quantum for preemptive scheduler is 1 unit time.
 
For each of the following algorithms:
(a) Round Robin;
(b) Shortest Remaining Time First;
 
Compute the turnaround time for A and B.
 
in Operating System
3.1k views

1 Answer

2 votes
2 votes
Best answer
For RR

$_{0}A_{1}B_{2}A_{3}B_{4}A_{6}//_{7}A_{8}B_{9}A_{10}B_{11}A_{13}$

at t=4 B goes for I/O which will be completed at t=8

at t=6 A goes for I/O which will be completed at t=7

at t=11 B goes for I/O which will be complete at t=15

at t=13 A goes form I/O which will be complete at t=14

TAT of A = Completion - Arrival = 14-0=14

TAT of B = Completion - Arrival = 15-0=15

SRTF

$_{0}A_{1}B_{3}A_{6}//_{7}A_{8}B_{10}A_{13}$

at t=10 B goes for I/O complete at 14

at t=13 A goes for I/O complete at 14

TAT A=B=14

or

$_{0}A_{1}B_{3}A_{6}//_{7}B_{9}A_{13}$

at t=9 B goes for I/O complete at 13

at t=13 A goes for I/O complete at 14

TAT A=14 B=13
selected by

2 Comments

Thanks a lot!
1
1
@Tesla!
for SJF why did u considered that A has come first
since it was given that DIFFERENCE IN THEIR ARRIVAL IS NEGLIGIBLE;
and even if A gets CPU first, how are u so sure that it will run for 1 ms only and then B will run??
i mean A can run for less than 1ms too!

according to me
Turnaround time for A=13; B=12
0
0

Related questions