Scheduling question

120 views
Skip to first unread message

Rahul Shah

unread,
Mar 6, 2012, 12:38:27 PM3/6/12
to asu-cse-430
Suppose a process has some time for computation and some I/O process
for its completion. (lets say for 5ms for CPU computation and 2 ms of
I/O). So does it context switch every time when it come across its I/O
execution part even though it is a non preemptive OR
does the CPU is idle for the I/O execution part and the process
completes in one go?

Partha Dasgupta

unread,
Mar 6, 2012, 2:01:08 PM3/6/12
to asu-c...@googlegroups.com
Assuming non preemptive scheduling.

Wherever the process request I/O is it context switched out. It does not "idle" and execute (busy wait), it is not executing when idle.


--
You received this message because you are subscribed to the Google Groups "asu-cse-430" group.
To post to this group, send email to asu-c...@googlegroups.com.
To unsubscribe from this group, send email to asu-cse-430...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asu-cse-430?hl=en.




--
Partha Dasgupta,
School of Computing Informatics, Arizona State University
EMail: par...@asu.edu
http://cactus.eas.asu.edu/partha

Rahul Shah

unread,
Mar 6, 2012, 9:03:16 PM3/6/12
to asu-cse-430
So in the problem given in the midterm(1 A). The process will be
context switched every 1 sec right?

Both process will take 9 sec to complete but because of the output of
a byte P1 will be completed at 17 sec and P2 at 18 sec

Also for the round robin should we consider quantum to be less than 1
sec ?

Partha Dasgupta

unread,
Mar 6, 2012, 9:55:23 PM3/6/12
to asu-c...@googlegroups.com
For non preemptive FIFO, the answer is (surprisingly) 9 secs and 10 secs (not 17 and 18).

For round robin, assume the quanta is << 1sec, and suddenly the quanta is not relevant to the answer.

Rahul Shah

unread,
Mar 6, 2012, 10:09:03 PM3/6/12
to asu-cse-430


P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

I assumed that the P1 will execute for the first 1 sec and at the end
of the 1st sec it will be blocked since it has to output the value
which takes 1 sec. So for the next 1 sec P2 will execute and at the
end of 2 sec P2 is blocked and P1 starts since it is done with its
output operation. The cycle continues this way.

Can you tell me where am I missing something?

Partha Dasgupta

unread,
Mar 6, 2012, 10:16:50 PM3/6/12
to asu-c...@googlegroups.com
Hint: Interleaving of IO and CPU. That is what you are missing. (those two can occur at the same time)

In your string, there should be 5 occurrences of P1 and 5 of P2.

mark_y...@hotmail.com

unread,
Mar 6, 2012, 10:28:07 PM3/6/12
to asu-cse-430
How does the output buffer affect the I/O cycle? Does it still require
an I/O cycle? If so, do we need to know how long it takes to output
1KB to the buffer?

Partha Dasgupta

unread,
Mar 6, 2012, 10:36:08 PM3/6/12
to asu-c...@googlegroups.com
IO time is the time taken to actually perform the IO on a device (disk). Since such devices are mechanical they are MUCH slower than memory. Writing to a memory buffer is orders of magnitude faster (negligible). Rule of thumb is that memory is 100 times faster. It may even be faster considering there is a lot of disk seeking going on.

Searching on google says disks can do about 50MB/s and memory can do over 1GB/s.

So it is safe to assume that moving to buffer takes 0 time. 

mark_y...@hotmail.com

unread,
Mar 6, 2012, 10:41:08 PM3/6/12
to asu-cse-430
But it will still cause an I/O context switch in non-preemptive
scheduling, right?

Partha Dasgupta

unread,
Mar 6, 2012, 10:43:21 PM3/6/12
to asu-c...@googlegroups.com
The mem copy (at the end of P1's CPU burst) will not context switch, as it needs CPU power to copy to memory. then it will context switch from P1 to P2 and while P1's 1 sec of disk output is going on, P1 will do its CPU burst. Hence the CPU will be 100% busy. Hence the results of 8 and 9 secs (ignoring mem buffer copy).

mark_y...@hotmail.com

unread,
Mar 6, 2012, 10:56:28 PM3/6/12
to asu-cse-430
I'm missing something. Aren't the cpu bursts still interleaved in FIFO
with the buffer? So you would still have P1 P2 P1 P2 P1 P2 P1 P2 P1 P2
-> 9 and 10 sec? where did we lose a second?

Partha Dasgupta

unread,
Mar 6, 2012, 11:01:03 PM3/6/12
to asu-c...@googlegroups.com
Yeah 9 and 10 secs. That is the answer. 
> P1 P2 P1 P2 P1 P2 P1 P2 P1 P2

The string above ... P1 ends after 9 and P2 ends after 10.

Rahul Shah

unread,
Mar 6, 2012, 11:03:15 PM3/6/12
to asu-cse-430
Got it!!... :)..

And for the next part with buffer the the turn around time would be 5
and 10 respectively since they don't get blocked because they are
outputing the value to the buffer?

Round robin: We consider the time quantum is very less so in the first
2 sec both the process will finish their 1st CPU burst of 1sec and for
the next 1 sec both process are doing Output operation. So the turn
around time is 14 sec for both the process.

For the round robin with buffer it would be 10 secs for both the
processes.

arbaz.v...@gmail.com

unread,
Mar 6, 2014, 2:49:50 AM3/6/14
to asu-c...@googlegroups.com
What if the data rate is 10 kbps burst time 1 sec and there are two identical processes.
Reply all
Reply to author
Forward
0 new messages