The efficiency of the two schemes is subjective long jobs have to wait longer

The efficiency of the two schemes is subjective long

This preview shows page 33 - 35 out of 102 pages.

The efficiency of the two schemes is subjective: long jobs have to wait longer if short jobs are moved in front of them, but if the distribution of jobs is random then we can show that the average waiting time of any one job is shorter in the SJF scheme, because the greatest number of jobs will always be executed in the shortest possible time. Of course this argument is rather stupid, since it is only the system which cares about the average waiting time per job, for its own prestige. Users who print only long jobs do not share the same clinical viewpoint. Moreover, if only short jobs arrive after one long job, it is possible that the long job will never get printed. This is an example of starvation . A fairer solution is required (see exercises below). Queue scheduling can be used for CPU scheduling, but it is quite inefficient. To understand why simple queue scheduling is not desirable we can begin by looking at a diagram which shows how the CPU and the devices are being used when a FCFS queue is used. We label each process by , ... etc. A blank space indicates that the CPU or I/O devices are in an idle state (waiting for a customer). Time CPU - - - devices - - - This diagram shows that starts out with a CPU burst. At some point it needs input (say from a disk) and sends a request to the device. While the device is busy servicing the request from , the CPU is idle, waiting for the result. Similarly, when the result returns, the device waits idle while the next CPU burst takes place. When is finished, is started and goes through the same kind of cycle. There are many blank spaces in the diagram, where the devices and the CPU are idle. Why, for example, couldn't the device be searching for the I/O for while the CPU was busy with and vice versa? We can improve the picture by introducing a new rule: every time one process needs to wait for a device, it gets put to the back of the queue. Now consider the following diagram, in which we have three processes. They will always be scheduled in order , , until one or all of them is finished. Time CPU -finishes -finishes - devices - - - - starts out as before with a CPU burst. But now when it occupies the device, takes over the CPU. Similarly when has to wait
Image of page 33
for the device to complete its I/O, gets executed, and when has to wait, takes over again. Now suppose finishes: takes over, since it is next in the queue, but now the device is idle, because did not need to use the device. Also, when finishes, only is left and the gaps of idle time get bigger. In the beginning, this second scheme looked pretty good - both the CPU and the devices were busy most of the time (few gaps in the diagram). As processes finished, the efficiency got worse, but on a real system, someone will always be starting new processes so this might not be a problem.
Image of page 34
Image of page 35

You've reached the end of your free preview.

Want to read all 102 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors