


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















department of computer science
CS 326 Operating Systems Greg Benson
Resource Scheduling ‣ An OS must decide who gets what resources and for how long ‣ Resources are usually allocated to processes ‣ CPU time ‣ Disk space ‣ Disk bandwidth ‣ Network bandwidth
Resource Decisions ‣ Allocation : Who gets what? ‣ Given a set of requests for resources, which processes should be given which resources for efficient use of the resources? ‣ Allocated resources are not preemptible ‣ Scheduling : How long can a process keep a resource? ‣ When more resources are requested than can be granted immediately, in which order should they be services? ‣ Examples: processor and memory
Process Scheduling ‣ How to allocate CPU time to processes? ‣ There may be many processes that can execute (waiting on the ready list) ‣ Recall the process states: ‣ Running: in execution on a CPU ‣ Ready: able to execute, the scheduler determines the transitions between this state and running ‣ Blocked: waiting for something, e.g., I/O, pipe data
Scheduling Analysis ‣ A process p requires t time to execute ‣ Arrival time: time when process enters the system ‣ Finish time: time process ends ‣ q is the quantum (timeslice) ‣ Response time ( T ): [Finish time] - [Arrival time]
FCFS: First-come First-served ‣ Run processes until completion ‣ Run processes in the order they arrive ‣ Very simple, easy to implement ‣ Often not used for process scheduling (no preemption) ‣ Use for other resources: printers, locks, pipes, etc.
FCFS Example 2 ‣ Three processes A, B, and C ‣ A.t = 10, B.t = 5, C.t = 3 ‣ Now assume that processes arrive in order B, C, A at time 0 ‣ B.T = 5, B.T= 8, C.T = 18 ‣ Average response time = (5 + 8 + 18) / 3 = 10. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 A A A A A A A A A A B B B B B C C C
SPN: Shortest Process Next ‣ Run processes in increasing order of service time ‣ Run processes to completion ‣ Minimize average response time ‣ Problems? ‣ Starvation ‣ Not practical
RR: Round Robin ‣ Run each process for one quantum, when a process finishes it’s quantum, put on the end of the ready list ‣ Each process gets equal share of CPU ‣ Most systems use some variant of RR ‣ The quantum length can effect performance and response time
RR Example ‣ Three processes A, B, and C ‣ A.t = 10, B.t = 5, C.t = 3 ‣ Assume that processes arrive at time 0 ‣ Quantum = 1 ‣ A.T = 18, B.T= 13, C.T = 9 ‣ Average response time = (18 + 13 + 9) / 3 = 13. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 A A A A A A A A A A B B B B B C C C
RR with Priorities ‣ Assign priority values to process (some processes more important than others) ‣ Lower value means higher priority ‣ E.g., 0 is highest, 4 is lowest ‣ Run higher priority processes before lower priority processes ‣ Processes at the same priority run in RR fashion ‣ Implementation: ‣ A single ready list ordered by priority. Ensure RR scheduling on processes with the same priorities. Simply run the process at the head of the list. ‣ Array ready lists: one entry for each priority level. Start at list 0 and 16 scan for first non-empty list. Use RR on each list.
RR with Priorities Example ‣ Three processes A, B, and C ‣ A.t = 10, B.t = 5, C.t = 3; A.p = 0, B.p = 0, C.p = 4 ‣ Assume that processes arrive at time 0 ‣ Quantum = 1 ‣ A.T = 15, B.T= 10, C.T = 18 ‣ Average response time = (15 + 10 + 18) / 3 = 14. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 A A A A A A A A A A B B B B B C C C
Multi-level Feedback ‣ Basic idea: SPN not practical. So, we want a way to approximate SPN. ‣ Give preference to short lived processes ‣ Introduce multiple queue, numbered 0, 1, 2, ... ‣ Processes on lower numbered queues have higher priority ‣ A process move up a queue at the end of a quantum q ‣ In general, q is chosen by a function, which can depend on the queue number. Examples: q =1 or q = 2^qnum
Scheduling Issues ‣ Non-preemptive algorithms are not suitable for multiprogrammed systems ‣ Most conventional operating systems use some form of RR with priorities and multi-level feedback ‣ Problems with priorities: ‣ Limit control over CPU allocation ‣ Give A a level of 1 and B a level of 10, but what does this really mean? ‣ Different systems have different priority values ‣ It would be better if we could say A gets 10% and B gets 90% of the CPU