CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.

Slides:



Advertisements
Similar presentations
Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Advertisements

Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Operating Systems Chapter 6
Chap 5 Process Scheduling. Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems CPU Scheduling. Agenda for Today What is Scheduler and its types Short-term scheduler Dispatcher Reasons for invoking scheduler Optimization.
CPU Scheduling Algorithms
Chapter 3: CPU Scheduling
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
02/06/2008CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
Scheduling in Batch Systems
Chapter 6: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Chapter 6: CPU Scheduling Basic.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
What we will cover…  CPU Scheduling  Basic Concepts  Scheduling Criteria  Scheduling Algorithms  Evaluations 1-1 Lecture 4.
Chapter 5-CPU Scheduling
7/12/2015Page 1 Process Scheduling B.Ramamurthy. 7/12/2015Page 2 Introduction An important aspect of multiprogramming is scheduling. The resources that.
02/11/2004CSCI 315 Operating Systems Design1 CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying.
CSC 539: Operating Systems Structure and Design Spring 2005
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Basic Concepts Maximum CPU utilization.
CPU-Scheduling Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The short term scheduler.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
CS212: OPERATING SYSTEM Lecture 3: Process Scheduling 1.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 6 CPU SCHEDULING.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
1 11/29/2015 Chapter 6: CPU Scheduling l Basic Concepts l Scheduling Criteria l Scheduling Algorithms l Multiple-Processor Scheduling l Real-Time 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 Basic.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 5 CPU Scheduling Slide 1 Chapter 5 CPU Scheduling.
6.1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Introduction to Operating System Created by : Zahid Javed CPU Scheduling Fifth Lecture.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling G.Anuradha Reference : Galvin. CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU SCHEDULING.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Operating System Concepts
Chapter5: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
CPU Scheduling: Basic Concepts
Presentation transcript:

CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and Dr. Hung)

The Fundamental Functions Process Management Memory Management File Management Input / Output Networking Utility Services

Process Management A process is a program in execution It is the basic unit of work on a computer It needs certain resources, e.g. CPU time, memory, files, I/O devices… to accomplish its task The OS is responsible for the following activities: Process creation and deletion Process suspension and resumption Provide mechanisms for: process synchronization process communication handling deadlock

Process States and Transitions During a process’ execution, it changes states New: the process is being created Running: instructions are being executed Waiting (blocked): the process is waiting for some event to occur (e.g., I/O operation) Ready: the process is waiting to be assigned to the CPU Terminated: the process has finished execution

Process Scheduling Why do we need to schedule processes? Multiple processes, single processor, time sharing Scheduler Short-term scheduler (CPU scheduler) invoked frequently (milliseconds), so must be fast Long-term scheduler (job scheduler) invoked infrequently (seconds or minutes), so may be slow Processes can be described as either: I/O-bound – more I/O than computations, many short CPU bursts. CPU-bound – more computations than I/O; few long CPU bursts. ideal: provide a mix of processes to fully utilize CPU and I/O devices Preemptive V.S. Non-preemptive Non-preemptive: once a process starts, it runs until it terminates or willingly gives up control, simple and efficient to implement Windows 3.1, early Mac OS Preemptive: process can be "forced" to give up the CPU (e.g., timeout, higher priority process), more sophisticated and powerful Windows 95/NT/XP…, UNIX

CPU Scheduling Criteria CPU Utilization: (time CPU is doing useful work)/(total elapsed time) want to keep the CPU as busy as possible in a real system, should range from 40% (light load) to 90% (heavy load) Throughput: Number of processes that complete their execution per time unit want to complete as many processes/jobs as possible actual number depends upon the lengths of processes (shorter  higher throughput) Turnaround Time: Average time to execute a process want to minimize time it takes from origination to completion again: average depends on process lengths Waiting Time: Average time a process has spent waiting in the ready queue want to minimize time process is in the system but not running less dependent on process length Response Time: Average time between submission of request and first response in a time-sharing environment, want to minimize interaction time for user

CPU Scheduling Criteria Different Systems have different concerns: In a batch system, throughput and turnaround time are key In an interactive system, response time is usually most important CPU scheduling may also be characterized with fairness … but, what is fairness? socialism? capitalism? A minimal definition of fairness: freedom from starvation starvation = indefinite blocking want to ensure that every ready job will eventually run (assuming arrival rate of new jobs ≤ max throughput of the system) note: fairness is often at odds with other scheduling criteria e.g., can often improve throughput or response time by making system less fair

Scheduling Algorithms First-Come, First-Served (FCFS) CPU executes job that arrived earliest Shortest-Job-First (SJF) CPU executes job with shortest time remaining to completion* Priority Scheduling CPU executes process with highest priority Round Robin (RR) like FCFS, but with limited time slices Multilevel queue like RR, but with multiple queues for waiting processes (i.e., priorities) Multilevel feedback queue like multilevel queue, except that jobs can migrate from one queue to another

First-Come, First-Served (FCFS) Scheduling The ready queue is a simple FIFO queue when a process enters the system, it is added to the rear of the queue when a process terminates/waits, process at front of queue is selected FCFS is non-preemptive once a process starts, it runs until it terminates or enters wait state (e.g., I/O) average waiting and turnaround times can be poor in general, non-preemptive schedulers perform poorly in a time sharing system since there is no way to stop a CPU-intensive process (e.g., an infinite loop)

FCFS Example Process Arrival Time Burst Time P P P Gantt Chart for the schedule is: average waiting time: ( )/3 = 15 average turnaround time: ( )/3 = 25 P1P1 P2P2 P3P

FCFS Example (a little different) Process Arrival Time Burst Time P P P Gantt Chart for the schedule is: average waiting time: ( )/3 = 1 average turnaround time: ( )/3 = 11 Convoy effect : short process behind long process degrades wait/turnaround times P1P1 P3P3 P2P

Shortest-Job-First (SJF) Scheduling The ready queue is not a simple FIFO queue associate with each process the length of its next CPU burst use these lengths to schedule the process with the shortest time Shortest- Job-First (SJF) scheduling SJF can be Non-preemptive or preemptive: Non-preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt known as Shortest-Remaining-Time-First (SRTF) Only if we can “ accurately ” predict CPU burst length, SJF is optimal it minimizes average waiting time for a given set of processes

SJF (Non-preemptive) Example Process Arrival Time Burst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4 Gantt Chart for the schedule is: average waiting time: ( )/4 = 4 average turnaround time: ( )/4 = 8 P1P1 P3P3 P2P P4P4 812

SJF (Preemptive) Example Process Arrival Time Burst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4 Gantt Chart for the schedule is: average waiting time: ( )/4 = 3 average turnaround time: ( )/4 = 7 P1P1 P3P3 P2P P4P4 57 P2P2 P1P1 16

Priority Scheduling Each process is assigned a numeric priority CPU is allocated to the process with the highest priority priorities can be external (set by user/admin) or internal (based on resources/history) SJF is priority scheduling where priority is the predicted next CPU burst time Priority scheduling may be preemptive or non-preemptive Non-preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt known as Shortest-Remaining-Time-First (SRTF) Priority scheduling is NOT fair: starvation is possible – low priority processes may never execute can be made fair using aging – as time progresses, increase the priority

Priority Scheduling Example Process Burst Time Priority P P2 1 1 P3 2 4 P4 1 5 P5 5 2 assuming processes all arrived at time 0, Gantt Chart for the schedule is: average waiting time: ( )/5 = 8.2 average turnaround time: ( )/5 = 12 P5P5 P3P3 P2P P4P P1P1

Round Robin (RR) Scheduling RR = FCFS with preemption time slice or time quantum is used to preempt an executing process timed out process is moved to rear of the ready queue some form of RR scheduling is used in virtually all operating systems If there are n processes in the ready queue and the time quantum is q each process gets 1/n of the CPU time in chunks of at most q time units at once no process waits more than (n-1)q time units. Performance if q is too large, response time suffers (reduces to FCFS) if q is too small, throughput suffers (spend all of CPU's time context switching) in practice, quantum of msec, context-switch of 0.1-1msec  CPU spends 1% of its time on context-switch overhead

RR Example ProcessArrival Time Burst Time P P P assuming q = 4, Gantt Chart for the schedule is: average waiting time: ( )/3 = 3.67 average turnaround time: ( )/3 = P1P1 P1P1 P1P P1P1 P2P2 P3P3 P1P1 P1P1

Multilevel Queue combination of priority scheduling and other algorithms (often RR) ready queue is partitioned into separate queues each queue holds processes of a specified priority each queue may have its own scheduling algorithm (e.g., RR for interactive processes, FCFS for batch processes) Must be scheduling among queues 1.absolute priorities 2.(uneven) time slicing

Multilevel Feedback Queue Similar to multilevel queue but processes can move between the queues e.g., a process gets lower priority if it uses a lot of CPU time a process gets a higher priority if it has been ready a long time (aging) Example: three queues Q0 – time quantum 8 msec Q1 – time quantum 16 msec Q2 – FCFS Scheduling new job enters queue Q0 which is served RR when it gains CPU, job receives 8 milliseconds if it does not finish in 8 milliseconds, job is moved to queue Q1. at Q1 job is again served RR and receives 16 additional milliseconds if it still does not complete, it is preempted and moved to queue Q2.