1 / 17

Chapter 5: Process Scheduling

Chapter 5: Process Scheduling. Chapter 5: CPU Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Objectives. To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various CPU-scheduling algorithms. Basic Concepts.

Download Presentation

Chapter 5: Process Scheduling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5: Process Scheduling

  2. Chapter 5: CPU Scheduling • Basic Concepts • Scheduling Criteria • Scheduling Algorithms

  3. Objectives • To introduce CPU scheduling, which is the basis for multiprogrammed operating systems • To describe various CPU-scheduling algorithms

  4. 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 • Process execution begins with a CPU burst…That is followed by an I/O burst, which is followed by another CPU burst, then another I/O burst, and so on. • Eventually, the final CPU burst ends with a system request to terminate execution

  5. Histogram of CPU-burst Times • The curve is generally characterized as exponential or hyper exponential • The durations of CPU bursts vary greatly from process to process. • There is large number of short CPU bursts and a small number of long CPU bursts. • An I/O-bound program >>>> has many short CPU bursts. • A CPU-bound program >>>> has a few long CPU bursts

  6. CPU Scheduler • CPU Scheduler (/ short-term scheduler): • Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them • The ready queue is not necessarily a first-in, first-out (FIFO) queue. It can be implemented as a FIFO queue, a priority queue, a tree, or an unordered linked list.

  7. Preemptive Scheduling • Preemptive Scheduling: • CPU scheduling decisions may take place when a process: • Switches from running to waiting state • Switches from running to ready state • Switches from waiting to ready • Terminates • Scheduling under 1 and 4 is non-preemptive (/cooperative). • Under non-preemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state • Scheduling under 2 and 3 is preemptive

  8. Dispatcher • Dispatcher : is the module gives control of the CPU to the process selected by the short-term scheduler. • The dispatcher should be as fast as possible, since it is invoked during every process switch. • Dispatch latency – time it takes for the dispatcher to stop one process and start another running

  9. Scheduling Criteria • CPU utilization – keep the CPU as busy as possible (represented as percentage) • Throughput – # of processes that complete their execution per time unit (e.g. 10 processes /sec) • Turnaround time – amount of time to execute a particular process • Turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU, and doing I/O. • Turnaround time is generally limited by the speed of the output device. • Waiting time – amount of time a process has been waiting in the ready queue • Waiting time is the sum of the periods spent waiting in the ready queue. • Response time – amount of time it takes from when a request was submitted until the first response is produced (for time-sharing environment) • It is the time it takes to start responding, not the time it takes to output the response.

  10. Scheduling Algorithm Optimization Criteria • Max CPU utilization • Max throughput • Min turnaround time • Min waiting time • Min response time

  11. Scheduling Algorithms

  12. Scheduling Algorithms • First-Come, First-Served Scheduling • Shortest-Job-First Scheduling • Priority Scheduling • Round-Robin Scheduling

  13. First-Come, First-Served (FCFS) Scheduling • The simplest CPU-scheduling algorithm • Basic methodology: The process that requests the CPU first is allocated the CPU first. • The implementation of the FCFS: • Using a FIFO queue: • When a process enters the ready queue, its PCB is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at the head of the queue. The running process is then removed from the queue. • FCFS algorithm is non-preemptive • Gantt chart: is a bar chart that illustrates a particular schedule, including the start and finish times of each of the processes.

  14. P1 P2 P3 0 24 27 30 First-Come, First-Served (FCFS) Scheduling • Example(1): Consider the following set of processes that arrive at time 0,with the length of the CPU burst given in milliseconds ProcessBurst Time(ms) P1 24 P2 3 P3 3 • Suppose that the processes arrive in the order: P1 , P2 , P3 • The Gantt Chart for the schedule is: • Waiting time for P1 = 0; P2 = 24; P3 = 27 • Average waiting time: (0 + 24 + 27)/3 = 17

  15. P2 P3 P1 0 3 6 30 FCFS Scheduling (Cont.) Example(2): Consider the same previous set of processes arrive at time 0,with the length of the CPU burst in milliseconds ProcessBurst Time(ms) P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P2 , P3 , P1 • The Gantt chart for the schedule is: • Waiting time for P1 = 6;P2 = 0; P3 = 3 • Average waiting time: (6 + 0 + 3)/3 = 3 >>>>Much better than example (1) • Convoy effect >>> short processes wait for the one big process to get off the CPU. • This effect results in lower CPU and device utilization than might be possible if the shorter processes were allowed to go first.

  16. FCFS Scheduling (Cont.) • FCFS Pros. (++): • Simplest algorithm • FCFS Cons. (--): • The average waiting time is generally not minimal and affected by processes’ order. • Lower CPU and device utilization because of convoy effect • Not suitable for time-shared systems

  17. End of Chapter 5

More Related