Download presentation
Presentation is loading. Please wait.
Published byDulcie Sims Modified over 8 years ago
1
INTRO TO PROCESS SCHEDULING Module 2.4 COP4600 – Operating Systems Richard Newman
2
Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved. NEED FOR PROCESS SCHEDULING Figure 2-39. Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. For good resource utilization, want to overlap I/O of on process with CPU burst of another process Recall process behavior...
3
MULTIPROGRAMMING For good resource utilization, want to overlap I/O of on process with CPU burst of another process
4
Assume jobs independent Probability of p a process is doing I/O Degree of multiprogramming is n (# processes) Probability of p n all n processes are doing I/O Probability that CPU is idle is p n CPU utilization is 1 - p n QUICK AND DIRTY MODEL
5
Figure 2-6. CPU utilization as a function of the number of processes in memory. Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved. MODELING MULTIPROGRAMMING
6
QUICK AND DIRTY MODEL Are we overestimating or underestimating CPU utilization?
7
Figure 2-25. Three-level scheduling. Long-term Short-term Medium-term THREE LEVEL SCHEDULING Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved. Do we have room for another? Processes in RAM contending for CPU Who gets CPU next? Is RAM over-subscribed?
8
Long-term (admission) scheduler: Has list of jobs waiting to be scheduled Decides whether to run a job on system Medium-term (memory) scheduler: Has set of currently running jobs and set of jobs that have been swapped out of memory Decides whether to swap a job in or out Short-term (CPU) scheduler: Has set of currently ready/running processes Decides which ready process to run next THREE TYPES OF SCHEDULER
9
Main goal for long-term (admission) scheduler: Get good mix of jobs in RAM Main goal for medium-term (memory) scheduler: Prevent thrashing (more on this later) Main goals for short-term (CPU) scheduler: Be efficient and fair All share goals of: Maximizing resource utilization Giving best service to clients Enforcing system policies THREE LEVEL SCHEDULING
10
Goal: Get good mix of jobs in RAM Need to predict job needs and behavior User-supplied (in job control information) Learned (same job run many times) Constraints: Memory – is there room to run the job? CPU cycles – what is CPU utilization? Other resources – does job need devices? More on these in memory management… ADMISSION SCHEDULER
11
Goal: Prevent thrashing (memory oversubscribed) Deals with demand paging/segmentation systems Detects problem by I/O vs. CPU utilization Constraints: Memory allocations to processes More on these in memory management… MEMORY SCHEDULER
12
Goals: Depend on type of system Information Externally provided info (e.g., priority) History of process kept by system Constraints: Any ready process may be selected But CPU scheduler runs often, so must be fast! CPU SCHEDULER
13
CPU scheduling is absolutely required: 1. When a process exits. 2. When a process blocks on I/O, or a semaphore. i.e. - when the running process can no longer run! CPU scheduling usually done (though not absolutely required): 1. When a new process is created. 2. When an I/O interrupt occurs. 3. When a clock interrupt occurs. i.e., when another process has higher priority WHEN TO SCHEDULE CPU Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
14
CATEGORIES OF SCHEDULING ALGORITHMS By job type, hence goals 1.Batch 2.Interactive 3.Real time Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved. By when run 1.Non-Preemptive 2.Preemptive
15
Figure 2-40. Some goals of the scheduling algorithm under different circumstances. Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved. SCHEDULING ALGORITHM GOALS
16
Criteria for deciding which process to choose: How long has it been since the process was swapped in or out? How much CPU time has the process had recently? How big is the process? (Small ones do not get in the way.) How important is the process? SCHEDULING DECISION CRITERIA Tanenbaum & Bos, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
17
Turn-around time = Finish time – arrival time includes time spent waiting for CPU Mean Turn-around Time (MTT) Average TT over all jobs Fairness – various measures, including maximum difference in fraction of time each job got CPU over some period Makespan = Finish time of last job – start time for set of jobs Used for multiprocessor scheduling Realtime deadlines met – (prob) for RTS systems SCHEDULING ALGORITHM MEASURES
18
A B C A takes 9 units of time if run by itself B takes 4 units of time if run by itself C takes 3 units of time if run by itself A B C A arrives at time 0 B arrives at time 1 C arrives at time 2 A running TT(A) = A arrives at time 0 A gets CPU CPU time Arrival time Schedule A B C B waiting C waiting B arrives at time 1 B must wait C arrives at time 2 C must wait B running C runs A finishes at time 9 Now B or C can run C finishes at time 12 Now B can run B finishes at time 16 All done! TT(B) =9 – 0 =9TT(C) =16 – 1 =1512 – 2 = (9+15+10)/3=MTT= 10 34/3 TURN-AROUND TIME
19
Non-preemptive algorithms: Running job must give up CPU/system voluntarily (system retains right/ability to terminate) First-Come First-Serve (FCFS): Jobs run in order of arrival Shortest Job First (SJF): Ready job that will finish first is run first Priority Ready job with highest priority is run first Optimal (Crystal Ball) Uses future knowledge of arrivals to optimize SCHEDULING ALGORITHMS
20
Preemptive algorithms: Running job may be forced to give up CPU/system involuntarily Round Robin (RR): Jobs run in order of arrival, with maximum quantum (go to end of queue if preempted) Shortest Remaining Time First (SRTF): Ready job that will finish first is run first Preemptive Priority: Ready job with highest priority is run first CTSS: Attempts to approximate SRTF SCHEDULING ALGORITHMS
21
Need for scheduling Keep resources utilized, meet timing goals, etc. Three-level scheduling Long-term admission scheduler Medium-term memory scheduler Short-term CPU scheduler Scheduling algorithm types & goals By job type: batch, interactive, real-time By when run: preemptive, non-preemptive Schedule metrics SUMMARY
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.