Thursday 5 November 2015

Scheduling

Scheduling

What is Scheduling?
Scheduling is the term the OS uses to define how and when a process is swapped in and out of the CPU, enabling multitasking. Each OS has a different way of performing scheduling. Scheduling makes decisions on which process should be run next or which ones should be interrupted, known as pre-empting.

external image Fig03_08.jpg

Scheduler Aims:
The main design goals of the scheduler are to:
  • Minimise starvation of processes (When a process doesn't get enough time or no time at all to run on the CPU)
  • Eliminate deadlock (When a process is waiting for a resource from another process so cannot access it, and this process is waiting for a resource held by the other, so neither can progress)
  • Ensure high throughput of processes (Processes can be completed as quickly as possible).
  • Ensure fairness for all processes (Linked to starvation).
  • Ensure reasonable response time (To enhance user experience).
The choice of a scheduling algorithm is to ensure these goals are met.

Disk Scheduling Vs Process Scheduling:

When you run a program, we would like to have it in CPU registers because is the fastest memory, but that is very expensive, so the programs (processes) are sent to RAM (also we would like to run many processes, more than the registers may keep). RAM soon or later will be full, we need to keep more programs on memory, so the next caching level is send the processes that aren't being used from RAM to disk.
  • The disk scheduling then consist in send to disk the processes that are not being used right now, but someday they will.
  • The process scheduling allows you to use many programs and apps in a "parallel" way (you see that everything is executing at the same time, but is just an illusion)


The strategies Deciding how jobs should be scheduled:
  • Shortest job first: the jobs are sorted into ascending order.
  • Round robin: each job is given a maximum length of processor time after which the job is put back in the queue.
  • Shortest remaining time: jobs in the ready queue are sorted into ascending order of the remaining processing time the job is expected to need.

Types of Strategy

Round Robin

This is the the simplest scheduling strategy that allows fairness in time on the CPU. This fairness is achieved as each process is given a fixed time to run and is pre-empted if the process has not completed before the end of that time. When processes aren't completed they are sent back to the ready to run queue and the head of the queue swaps into the CPU, this will continue until all processes are completed.

Priority Scheduling

This approach is very good for making sure that the most vital jobs get to run first however, it must also deal with low-priority jobs, otherwise they may never get a look-in. In this case the scheduler may start to bump up the priority of lower jobs to ensure they will eventually run.

Shortest Burst

This approach the idea is to get as many jobs through the CPU as possible. Many jobs spend a considerable of time waiting for some input-output event to happen, and then they run for a bit and once again they have to wait for another input-output event.This strategy schedules the shortest job to be processed first.

No comments:

Post a Comment