4.7k views

Suppose two jobs, each of which needs $10$ minutes of CPU time, start simultaneously. Assume $50\%$ I/O wait time. How long will it take for both to complete, if they run sequentially?

1. 10
2. 20
3. 30
4. 40
| 4.7k views
0
In the above question there is mentioned two jobs starts simultaneously ..Which states same arrival time for both process (ie 0) . Then it asked how long it will take for both if they run sequentially  ?

Here "sequentially " states scheduling algorithm to be FCFS
0

The distribution of I/O and CPU burst times isn't explicitly mentioned, so if we take assumption liberties how's this solution wrong? t = 20.

"50% I/O wait time." mean 50% of the time CPU is waiting for IO.

ie: if total CPU time is 2x, then x times its doing IO operation and other x time it is running the process.

Now, calculate how much time CPU is running the process, it is 10+10 mins.(take processes in any order).

ie, x=20 mins, so 2x=40mins.

by Active (3k points)
selected by
–1
CPU TIME = 10 min, IO Time = 50% i.e. 50% for CPU & 50% for IO. (it is not 50% of CPU time, read question again)
IO time = CPU Time = 10ms

t=0 to 10ms,
A completes its CPU Burst.

t= 10 to 20,
B completes CPU & at same time A Complete its IO burst.

t=20 to 30,
B completes its IO.

Total time is 30ms.
by Veteran (60.9k points)
edited
0
" 50% I/O wait time." Does this mean 50% of the time CPU is waiting for IO?
0
40 is the ans
0
Consider a case if first process runs till 9.9 minutes and then goes for I/O for 10 minutes...here at the same time you can't go for second process execution after 9.9 minutes.Because in question they have clearly mentioned that they are running sequentially so you can't switch to another process in between until first process execution finishes completely.Therefore after I/O it will again come back to cpu and execute for their remaining 0.1 minute.So first process runs till 20 minutes and second process will also run for 20 minutes,therefore total time will be 40.
+1
@ajit parallel execution doesn't mean that. When one process is blocked next one do come for execution even in a sequential machine. The question is confusing - should not have been asked like this.
0
YES it seems confusing.

Is it mandatory to have two processors atleast for parallel execution?
0
Yes. But if you have studied "pipelining" there we can mix the instructions of two processes - multitasking - and suppose in hardware we have 2 adder units, then two "ADD" instructions from 2 processes can be done in parallel (at same time). This might be complex but for simple case, you can say parallel execution requires multiple hardware units - 2 or more CPUs.
0
But what is the meaning of sequential in this question??

if cpu is doing execution of process as well as i/o is also being carried out then what does this mean?
0
IO wait time is not part of execution and has no effect in making an execution parallel. It is like just waiting for the user to enter something (scanf in C). If we talk about IO processing this requires CPU- but this question is clear in this regard.
0
You mean I/O wait time and I/O burst time both are different thing.

I/O wait time-> Waiting for user to enter something

I/O Burst time-> Waiting for resources which is aquired by other process
0
Not really. Both are same. IO burst means CPU is not working (vs CPU burst) - but saying as "IO wait" avoids any confusion.
0
okay finally......why @Digvijay answer is wrong?

The method they are following can never occur??
0

Due to the ambiguity of this line: "Assume 50%50% I/O wait time"

In the accepted answer it was assumed that is the total CPU time is $x$, then $x$ time would have been idle also. So, totally $2x$ time considering all the processes (not individually).

In the answer by Digvijay, he took like if CPU burst is $x$, then IO burst is also $x$ per process.

0
But why do you think we should consider overall case,not individually?Which is stronger?

By the question how can we understand how to approach??

It doesn't look ambiguous??
0
yes, it is. I feel it is ambiguous.
 50% I/O wait time means that a process is not in execution(i.e. CPU is sitting idle) for 50% of the total time a process requires from CPU to complete itself(its execution). Thus CPU Utilization turns out to be //whereas 50% I/O time means it needs 50% of total execution time(10 minutes) to complete its I/O. 50%=50/100 = .5 thus the time needed to complete a process which requires 10 minute of CPU will be = CPU time required by process/CPU utilization= 10/CPU utilization= 10/0.5 = 20 minutes. when two processes run sequentially(one after the other) then the total time required will be = 10/0.5 + 10/0.5 = 20+20=40 minutes (ANSWER) in case of parallel execution we again find the CPU utilization.. since two processes are in parallel thus the formulae becomes--> {1-(I/O time)^no. of processes in parallel execution} =1-(0.5)^2=1-.25=0.75 now the CPU utilization for 1 process will be 0.75/2=0.375 Therefore the time required will be = CPU time required by process/CPU utilization= 10/0.375=26.67 minutes. Since the two processes are running in parallel thus the time required by 1 process will be the total time required by 2 process=26.67 minutes
by (319 points)
option c .
Total time of one process=cpu time + I/O time=10+5=15
Since they are executing sequencially. So total time 15+15=30
by Active (3.1k points)
0
1. IO =50%ofCPU is it given ??

2. Let IO is 5ms then ??

IO shouldn't overlapped ?? (Sequential means CPU burst should be in sequence only).

10ms (for Process A CPU burst) + 10ms (for process B CPU and at same time completes its IO) + 5ms(Process B IO) = 25ms

Ans is B

Since order of cpu and i/o is not mentioned in the question .so we shall arrange the process in the following order:

Process        Arr-Time     CPU Time               I/O Time      CPU Time

P1                 0               5                                5              5

P2                 0               5                                5              5

Now the Gantt chart:

0                             5       P1 I/0               10   P2 I/O              1 5                        20

 p1 p2 p1 p2

So it will take Total time=20 min

by (315 points)
–1 vote

CPU time is 10 minutes (given).

I/O time is 50% of the total time means total time is 20 minutes (10 minutes CPU time, 10 minutes I/O time).

Now for one process total time is 20 minutes. for two processes total time is:-

case 1: if they run Sequentially then overlapping is not allowed and total time is 40 minutes

case 2: if overlapping is allowed (Parallel processing) then I/O time of P1 can be overlapped with CPU time of P2. In this case the total time will be 30 minutes

by (19 points)
edited