Operating System Concepts - Chapter 5: CPU Scheduling pdf

51 1.8K 0
Operating System Concepts - Chapter 5: CPU Scheduling pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling  Basic ConceptsScheduling Criteria  Scheduling Algorithms  Multiple-Processor Scheduling  Real-Time Scheduling  Thread SchedulingOperating Systems Examples  Java Thread Scheduling  Algorithm Evaluation 5.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Basic Concepts  Maximum CPU utilization obtained with multiprogramming  CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait  CPU burst distribution 5.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Alternating Sequence of CPU And I/O Bursts Alternating Sequence of CPU And I/O Bursts 5.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Histogram of CPU Histogram of CPU - - burst Times burst Times 5.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 CPU Scheduler CPU Scheduler  Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them  CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates  Scheduling under 1 and 4 is nonpreemptive  All other scheduling is preemptive 5.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Dispatcher Dispatcher  Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves: z switching context z switching to user mode z jumping to the proper location in the user program to restart that program  Dispatch latency – time it takes for the dispatcher to stop one process and start another running 5.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Scheduling Criteria Scheduling Criteria  CPU utilization – keep the CPU as busy as possible  Throughput – # of processes that complete their execution per time unit  Turnaround time – amount of time to execute a particular process  Waiting time – amount of time a process has been waiting in the ready queue  Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment) 5.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Optimization Criteria Optimization Criteria  Max CPU utilization  Max throughput  Min turnaround time  Min waiting time  Min response time 5.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 First First - - Come, First Come, First - - Served (FCFS) Scheduling Served (FCFS) Scheduling Process Burst Time P 1 24 P 2 3 P 3 3  Suppose that the processes arrive in the order: P 1 , P 2 , P 3 The Gantt Chart for the schedule is:  Waiting time for P 1 = 0; P 2 = 24; P 3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17 P 1 P 2 P 3 24 27 300 [...]... scheduling Linux scheduling Operating System Concepts – 7th Edition, Feb 2, 2005 5.33 Silberschatz, Galvin and Gagne ©2005 Solaris 2 Scheduling Operating System Concepts – 7th Edition, Feb 2, 2005 5.34 Silberschatz, Galvin and Gagne ©2005 Solaris Dispatch Table Operating System Concepts – 7th Edition, Feb 2, 2005 5.35 Silberschatz, Galvin and Gagne ©2005 Windows XP Priorities Operating System Concepts –... the system data structures, alleviating the need for data sharing Operating System Concepts – 7th Edition, Feb 2, 2005 5.28 Silberschatz, Galvin and Gagne ©2005 Real-Time Scheduling Hard real-time systems – required to complete a critical task within a guaranteed amount of time Soft real-time computing – requires that critical processes receive priority over less fortunate ones Operating System Concepts. .. τn+1 = α tn Only the actual last CPU burst counts If we expand the formula, we get: τn+1 = α tn+(1 - α)α tn -1 + … +(1 - α )j α tn -j + … +(1 - α )n +1 τ0 Since both α and (1 - α) are less than or equal to 1, each successive term has less weight than its predecessor Operating System Concepts – 7th Edition, Feb 2, 2005 5.17 Silberschatz, Galvin and Gagne ©2005 Priority Scheduling A priority number (integer)... does not complete, it is preempted and moved to queue Q2 Operating System Concepts – 7th Edition, Feb 2, 2005 5.26 Silberschatz, Galvin and Gagne ©2005 Multilevel Feedback Queues Operating System Concepts – 7th Edition, Feb 2, 2005 5.27 Silberschatz, Galvin and Gagne ©2005 Multiple-Processor Scheduling CPU scheduling more complex when multiple CPUs are available Homogeneous processors within a multiprocessor... using the length of previous CPU bursts, using exponential averaging 1 t n = actual length of n th CPU burst 2 τ n +1 = predicted value for the next CPU burst 3 α , 0 ≤ α ≤ 1 τ n =1 = α t n + (1 − α )τ n 4 Define : Operating System Concepts – 7th Edition, Feb 2, 2005 5.15 Silberschatz, Galvin and Gagne ©2005 Prediction of the Length of the Next CPU Burst Operating System Concepts – 7th Edition, Feb... Shortest-Remaining-Time-First (SRTF) SJF is optimal – gives minimum average waiting time for a given set of processes Operating System Concepts – 7th Edition, Feb 2, 2005 5.12 Silberschatz, Galvin and Gagne ©2005 Example of Non-Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (non-preemptive) P1 0 3 P3 7 P2 8 P4 12 16 Average waiting time = (0 + 6 + 3 + 7)/4 = 4 Operating. .. Pthread Scheduling API /* now join on each thread */ for (i = 0; i < NUM THREADS; i++) pthread join(tid[i], NULL); } /* Each thread will begin control in this function */ void *runner(void *param) { printf("I am a thread\n"); pthread exit(0); } Operating System Concepts – 7th Edition, Feb 2, 2005 5.32 Silberschatz, Galvin and Gagne ©2005 Operating System Examples Solaris scheduling Windows XP scheduling. .. attributes */ pthread attr init(&attr); /* set the scheduling algorithm to PROCESS or SYSTEM */ pthread attr setscope(&attr, PTHREAD SCOPE SYSTEM) ; /* set the scheduling policy - FIFO, RT, or OTHER */ pthread attr setschedpolicy(&attr, SCHED OTHER); /* create the threads */ for (i = 0; i < NUM THREADS; i++) pthread create(&tid[i],&attr,runner,NULL); Operating System Concepts – 7th Edition, Feb 2, 2005 5.31 Silberschatz,... Context Switch Time Operating System Concepts – 7th Edition, Feb 2, 2005 5.21 Silberschatz, Galvin and Gagne ©2005 Turnaround Time Varies With The Time Quantum Operating System Concepts – 7th Edition, Feb 2, 2005 5.22 Silberschatz, Galvin and Gagne ©2005 Multilevel Queue Ready queue is partitioned into separate queues: foreground (interactive) background (batch) Each queue has its own scheduling algorithm... Silberschatz, Galvin and Gagne ©2005 Multilevel Queue Scheduling Operating System Concepts – 7th Edition, Feb 2, 2005 5.24 Silberschatz, Galvin and Gagne ©2005 Multilevel Feedback Queue A process can move between the various queues; aging can be implemented this way Multilevel-feedback-queue scheduler defined by the following parameters: number of queues scheduling algorithms for each queue method used . Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling . Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Multiple-Processor Scheduling  Real-Time Scheduling  Thread Scheduling  Operating Systems Examples  Java Thread Scheduling . ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Shortest Shortest - - Job Job - - First (SJF) Scheduling First (SJF) Scheduling  Associate with each process the length of its next CPU

Ngày đăng: 28/06/2014, 02:20

Từ khóa liên quan

Mục lục

  • Chapter 5: CPU Scheduling

  • Chapter 5: CPU Scheduling

  • Basic Concepts

  • Alternating Sequence of CPU And I/O Bursts

  • Histogram of CPU-burst Times

  • CPU Scheduler

  • Dispatcher

  • Scheduling Criteria

  • Optimization Criteria

  • First-Come, First-Served (FCFS) Scheduling

  • FCFS Scheduling (Cont.)

  • Shortest-Job-First (SJF) Scheduling

  • Example of Non-Preemptive SJF

  • Example of Preemptive SJF

  • Determining Length of Next CPU Burst

  • Prediction of the Length of the Next CPU Burst

  • Examples of Exponential Averaging

  • Priority Scheduling

  • Round Robin (RR)

  • Example of RR with Time Quantum = 20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan