Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scheduling.

Similar presentations


Presentation on theme: "Scheduling."— Presentation transcript:

1 Scheduling

2 What is Scheduling? Selecting the next process (or thread) to be executed. Happens when: Current process has consumed enough time (assuming a pre-emptive scheduler) Current process performs an OS operation (such as wait or give a semaphore).

3 Process Table The scheduler uses information from the process table to decide which process (thread) to run next. When the scheduler is active, it only considers processes that are in the “Ready” state.

4 Round Robin Time is divided into small slices called quantum.
Each process is given a slice of time in which to operate. If the process calls the OS in the time slice it gives up the rest of the slice. The process is interrupted at the end of the time slice.

5 Round Robin The scheduler maintains an entry in the process table of the most recent time slice number. The scheduler picks the process that has the smallest time slice. Very fair algorithm in that everybody has an equal amount of time to use the CPU.

6 Responsiveness If you had a time slice size of 5 seconds (never this big!) and 2 processes (Explorer and Word) it means that MS Word could have to wait up to 5 seconds before it could process a key that you typed. Responsiveness of applications is inversely related to the size of the slices. (small slice = highly responsive)

7 Inefficient Small slices means a lot of rescheduling
Rescheduling means CPU is not letting applications run. An OS could spend more time deciding what to do than actually doing it.

8 Priority Based Scheduling
There are often times where certain things are more important than others. Many OS provide for priorities to be given to processes. When the scheduler is run, it looks for the highest priority process that is Ready.

9 Priorities Depends on the OS Could be: High, Medium, Low
Could be integer values: 0 through 255 Large number could mean high or low!! The OS may use round robin scheduling if there are several processes with the same priority.

10 Algorithm Scheduler picks the highest priority process that is in Ready state. Each time the process requests an OS operation the scheduler is activated. An OS call could make a semaphore available which may wake up a blocked process with a higher priority! Usually at the end of every time slice the scheduler is also activated.

11 Potential Problems A high priority process with no blocking can monopolize the CPU. The typical design pattern is to ensure that high priority processes do not require a lot of time before they block….very tricky design. Some OS may limit a process ability to change the priority.

12 Priority Selection is Difficult
Selecting the correct priority is not always obvious. It is easy to select wrong Requires analysis (math calculations) to get it right. Priority based scheduling is critical in “real-time” systems. Real time system is a computer that has a deadline to complete a task.

13 Important = Priority? Example involving coffee.

14 Priority Problems A high priority task waiting for a low priority task is a bad combination.

15 Other Scheduling Algorithms
Many other algorithms exist but are priority used for batch processing. Batch processing Processes running without user interaction Usually all processes are known in advance. Batch systems are not used frequently today.

16 First Come First Serve The only switch happens when the program completes. Not good if two processes are cooperatively solving a problem.

17 Shortest Task Remaining
Scheduler uses the amount of CPU time remaining to select the next job to be scheduled. Short new processes get to run sooner than longer processes. Not easy to determine how much time is actually remaining in the general case.


Download ppt "Scheduling."

Similar presentations


Ads by Google