0

Problem :

Five batch jobs A through E, arrive at a computer center at almost the same time. They have estimated running times 10, 6, 2, 4, and 8 minutes. Their (externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. Determine the mean process turn around time. Ignore process switching overhead. For Round Robin Scheduling, assume that the system is multiprogramming, and that each job gets it fair share of the CPU.All jobs are completely CPU bound.

Solution #1 The following solution comes from this page :

For round robin, during the first 10 minutes, each job gets 1/5 of the CPU. At the end of the 10 minutes, C finishes. During the next 8 minutes, each job gets 1/4 of the CPU, after which time D finishes. Then each of the three remaining jobs get 1/3 of the CPU for 6 minutes, until B finishes and so on. The finishing times for the five jobs are 10, 18, 24. 28, 30, for an average of 22 minutes.

Solution #2 the following solution comes from Cornell University here, which is different (and this one makes more sense to me) :

Remember that the turnaround time is the amount of time that elapses between the job arriving and the job completing. Since we assume that all jobs arrive at time 0, the turnaround time will simply be the time that they complete. (a) Round Robin: The table below gives a break down of which jobs will be processed during each time quantum. A * indicates that the job completes during that quantum.

1 2 3 4 5  6 7 8  9 10  11 12 13 14  15 16 17 18  19 20 21  22 23 24  25 26  27 28  29 30  
A B C D E  A B C* D E   A  B  D  E   A  B  D* E   A  B  E   A  B* E   A  E   A  E*  A  A*

The results are different: In the first one C finishes after 10 minutes, for example, whereas in the second one C finishes after 8 minutes.

Which one is the correct one and why? I'm confused.. Thanks in advance!

1 Answers1

1

Q1: I believe that the "fair share" requirement means you can assume the time is evenly divided amongst running processes, and thus the particular order won't matter. You could also think of this as the quantum being so low that any variation introduced by a particular ordering is too small to worry about.

Q2: From the above, assuming the time is evenly divided, it will take 10 minutes for all processes to get 2 minutes of their own, at which point C will be done.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • regarding Q2.. Why does C finish after all processes have had 2 minutes of their own and not after C has had 2 minutes of its own (which is after 8 minutes) Since it will take 10 mins for all processes to have 2 mins of their own that means everything is happening sequentially on job after another, you're making ti sound as if C is at the end of the list –  Mar 28 '12 at 19:22
  • 1
    @user1073400: Imagine a quantum of 1 MICROSECOND; then, no matter what order, so long as the time is fairly divided, C will finish after every other process has run between 2-(1 MICROSECOND) and 2 minutes. – Scott Hunter Mar 28 '12 at 19:28
  • I still don't understand why. I found another solution online from Cornell University which makes more sense to me and I added it at the end of my original post. Have a look and tell me what you think. –  Mar 28 '12 at 19:39
  • What do you have as definition for what it means for each job to get its "fair share" of the CPU? And do you not understand the reasoning if the quantum were so low, or WHY it should be so low? – Scott Hunter Mar 28 '12 at 19:42
  • 1
    Please explain how C finishes in 8 minutes if quantum is 1 msec. And if that;'s what fair share meant, then it is redundant (since a quantum, by definition, is the amount of time ANY process gets before being interrupted). Since the question explicitly mentions fair-share, it must mean something else. – Scott Hunter Mar 28 '12 at 20:04
  • Unfortunately none of the two links I provided give any more details as to what they mean by fair share but they certainly do give different solutions to the same question which is rather confusing and I'm trying to understand why. (You're right about the 1msec thing though.. still what about the contradicting solutions? ) –  Mar 28 '12 at 20:18
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/9427/discussion-between-scott-hunter-and-user1073400) – Scott Hunter Mar 28 '12 at 20:36
  • To make my question, as well as a possible answer, simpler I reformulated my question [here](http://stackoverflow.com/questions/9917199/round-robin-scheduling-two-different-solutions-how-is-that-possible). Feel free to check that out as well. –  Mar 28 '12 at 23:42