-1
$\begingroup$

Can anyone please help me with the following question?

Consider a single processor system supporting two running processes, A and B, with the following sequential execution patterns:

A: [CPU 8 ms; IO 1 ms; CPU 8 ms; IO 1 ms; CPU 8 ms]

B: [CPU 2 ms; IO 1 ms; CPU 2 ms; IO 1 ms; CPU 2 ms]

Assume that IO operations do not interfere with each other and are blocking, and that scheduling and context switch times are negligible.

a) What is the total elapsed time for the two processes to run to completion?

b) Assume the system runs a non-preemptive scheduler where processes are scheduled in the order in which they become runnable, and that B takes priority over A in the event of a tie. Give the combined execution pattern of the two processes in the format as in part (ii), and determine the total elapsed time for the two processes to run to completion.

c) Repeat part (ii) b) with a pre-emptive scheduler operating with a time slice of 4ms.

d) What are the costs and the benefits of a pre-emptive scheduler over a non- preemptive scheduler for this workload, which would you choose, and why?

$\endgroup$

closed as unclear what you're asking by Evil, xskxzr, Discrete lizard Apr 1 at 20:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ What kind of help do you seek? For now it looks like verbatim copy of some excersise. What have you tried? Where did you get stuck? $\endgroup$ – Evil Mar 30 at 2:38
  • $\begingroup$ It is. And I have no idea how to answer this. therefore any kind of help would be highly appreciated $\endgroup$ – Lee Marsden Mar 30 at 2:48
  • $\begingroup$ Please credit the original source of the problem in the question. You must always acknowledge the source of all copied material. $\endgroup$ – D.W. Mar 30 at 18:58
  • $\begingroup$ We're happy to help you understand the concepts but just solving exercises for you is unlikely to achieve that. You might find this page helpful in improving your question. $\endgroup$ – D.W. Mar 30 at 18:58
  • $\begingroup$ Cross-posted: cs.stackexchange.com/q/106244/755, stackoverflow.com/q/55427281/781723. Please do not post the same question on multiple sites. Each community should have an honest shot at answering without anybody's time being wasted. $\endgroup$ – D.W. Mar 30 at 18:59
0
$\begingroup$

Non-preemptive, starting with job A, does 8ms on job A, 2 ms on job B, 8 ms on job A, 2 ms on job B, 8 ms on job A, 2ms on job B. I/O is performed while the other job uses the CPU, so is free. Job A finishes after 28 ms, job B after 30 ms.

If you had started with thread B, B would have finished after 22 ms, A after 30.

You could finish B substantially faster by giving it higher priority: 2ms job B, 1ms job A (while B performs i/o), 2ms job B, 1ms job A, 2ms job B, then job A finishes without getting the I/O for free. B finishes after 8ms, A after 32ms.

If we preempt after 4ms, if we start with A, we run A for 4ms, B for 2ms, A for 4ms, B for 2ms, A for 4ms, B for 2ms, then A for 4 ms, 1ms I/O, A for 8ms. Takes 18ms for B, 31ms for A. You get different numbers if you start with B.

This is all quite unsatisfactory. Without preemption, and with little I/O, the execution time of each job is basically dependent on the number of I/O operations, because we switch on I/O operations. However, if we give priority to the job that takes fewer resources, it can finish much faster - unsatisfactory, because we don't know which job takes fewer resources.

Preemption after 4ms makes the process using less CPU time finish faster.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.