Scheduling. The Basics

Similar documents
Scheduling of processes

Chapter 5: CPU Scheduling

1.1 CPU I/O Burst Cycle

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Unit 3 : Process Management

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Chapter 9. Uniprocessor Scheduling

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

8: Scheduling. Scheduling. Mark Handley

Topic 4 Scheduling. The objective of multi-programming is to have some process running at all times, to maximize CPU utilization.

Ch 4 : CPU scheduling

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

Preview. Process Scheduler. Process Scheduling Algorithms for Batch System. Process Scheduling Algorithms for Interactive System

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

CPU Scheduling Algorithms

Chapter 9 Uniprocessor Scheduling

Uniprocessor Scheduling. Chapter 9

Last Class: Processes

Operating Systems: Quiz2 December 15, Class: No. Name:

Operating System Concepts Ch. 5: Scheduling

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

Operating Systems. Scheduling

Process- Concept &Process Scheduling OPERATING SYSTEMS

CS370 Operating Systems

CS3733: Operating Systems

Scheduling. Scheduling. Scheduling. Scheduling Criteria. Priorities. Scheduling

Process behavior. Categories of scheduling algorithms.

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

Subject Teacher: Prof. Sheela Bankar

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

CS 153 Design of Operating Systems Winter 2016

Process Scheduling. Copyright : University of Illinois CS 241 Staff

CSE 120 Principles of Operating Systems

A COMPARATIVE STUDY OF CPU SCHEDULING POLICIES IN OPERATING SYSTEMS

Operating Systems Unit 3

CPU Scheduling. Schedulers. CPSC 313: Intro to Computer Systems. Intro to Scheduling. Schedulers in the OS

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

Properties of Processes

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

CS370 Operating Systems

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Chapter 6: CPU Scheduling

Operating System Review Part

COSC243 Part 2: Operating Systems

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31

3. CPU Scheduling. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

CPU Scheduling: Objectives

Operating Systems. Lecture Process Scheduling. Golestan University. Hossein Momeni

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

Uniprocessor Scheduling

Scheduling Bits & Pieces

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Scheduling

Operating Systems ECE344. Ding Yuan

Uniprocessor Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms. Three level scheduling

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Chapter 5: CPU Scheduling

Subject Name: OPERATING SYSTEMS. Subject Code: 10EC65. Prepared By: Kala H S and Remya R. Department: ECE. Date:

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

CPU Scheduling (1) CPU Scheduling (Topic 3) CPU Scheduling (2) CPU Scheduling (3) Resources fall into two classes:

CSE 120 Principles of Operating Systems Spring 2017

Scheduling in the Supermarket

LECTURE 3:CPU SCHEDULING

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

Chapter 5: CPU Scheduling

Start of Lecture: February 10, Chapter 6: Scheduling

CSL373: Lecture 6 CPU Scheduling

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

Chapter 5: CPU Scheduling. Operating System Concepts Essentials 8 th Edition

CS370 Operating Systems

Frequently asked questions from the previous class survey

Course Syllabus. Operating Systems

Operating Systems. Figure: Process States. 1 P a g e

CS307: Operating Systems

Chapter 6: CPU Scheduling

The Deadlock Problem (1)

CSE 4/521 Introduction to Operating Systems

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition,

CISC 7310X. C05: CPU Scheduling. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 3/1/2018 CUNY Brooklyn College

CHAPTER 2: PROCESS MANAGEMENT

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

High level scheduling: Medium level scheduling: Low level scheduling. Scheduling 0 : Levels

Operating Systems. Process scheduling. Thomas Ropars.

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

Practice Exercises 305

Operating Systems CS 323 Ms. Ines Abbes

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

Chapter 5 CPU scheduling

Frequently asked questions from the previous class survey

Today s class. Scheduling. Informationsteknologi. Tuesday, October 9, 2007 Computer Systems/Operating Systems - Class 14 1

UNIT:2. Process Management

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

Transcription:

The Basics refers to a set of policies and mechanisms to control the order of work to be performed by a computer system. Of all the resources in a computer system that are scheduled before use, the CPU is by far the most important. Multiprogramming is the (efficient) scheduling of the CPU. The basic idea is to keep the CPU busy as much as possible by executing a (user) process until it must wait for an event, and then switch to another process. Processes alternate between consuming CPU cycles (CPU-burst) and performing I/O (I/O-burst).

Types of In general, (job) scheduling is performed in three stages: short-, medium-, and long-term. The activity frequency of these stages are implied by their names. Long-term (job) scheduling is done when a new process is created. It initiates processes and so controls the degree of multi-programming (number of processes in memory). Medium-term scheduling involves suspending or resuming processes by swapping (rolling) them out of or into memory. Short-term (process or CPU) scheduling occurs most frequently and decides which process to execute next.

Long-Term and Medium-Term Acting as the primary resource allocator, the longterm scheduler admits more jobs when the resource utilization is low, and blocks the incoming jobs from entering the ready queue when utilization is too high. When the main memory becomes over-committed, the mediumterm scheduler releases the memory of a suspended (blocked or stopped) process by swapping (rolling) it out. In summary, both schedulers control the level of multiprogramming and avoid (as much as possible) overloading the system by many processes and cause thrashing.

Short-Term Short-term scheduler, also known as the process or CPU scheduler, controls the CPU sharing among the ready processes. The selection of a process to execute next is done by the short-term scheduler. Usually, a new process is selected under the following circumstances: When a process must wait for an event. When an event occurs (e.g., I/O completed, quantum expired). When a process terminates.

Short-Term Criteria The goal of short-term scheduling is to optimize the system performance, and yet provide responsive service. In order to achieve this goal, the following set of criteria is used: CPU utilization I/O device throughput Total service time Responsiveness Fairness Deadlines

Algorithms The following are some common scheduling algorithms: Non-preemptive First-Come-First-Served (FCFS) Shortest Job First (SJF) Background batch Good for jobs Preemptive Round-Robin (RR) Priority Foreground Good for interactive jobs In general, scheduling policies may be non-preemptive. In a nonpreemptive pure multiprogramming system, the short-term scheduler lets the current process run until it blocks, waiting for an event or a resource, or it terminates. Preemptive policies, on the other hand, force the currently active process to release the CPU on certain events, such as a clock interrupt, some I/O interrupts, or a system call.

First Come First Serve (FCFS) FCFS, also known as First-In-First-Out (FIFO), is the simplest scheduling policy. Arriving jobs are inserted into the tail (rear) of the ready queue and the process to be executed next is removed from The head (front) of the queue. FCFS performs better for long jobs. Relative importance of jobs measured only by arrival time (poor choice). A long CPU -bound job may hog the CPU and may force shorter (or I/O-bound) jobs to wait prolonged periods. This in turn may lead to a lengthy queue of ready jobs, and thence to the convoy effect.

Shortest Job First (SJF) SJF policy selects the job with the shortest (expected) processing time first. Shorter jobs are always executed before long jobs. One major difficulty with SJF is the need to know or estimate the processing time of each job (can only predict the future!) Also, long running jobs may starve, because the CPU has a steady supply of short jobs.

Round Robin (RR) RR reduces the penalty that short jobs suffer with FCFS by preempting running jobs periodically. The CPU suspends the current job when the reserved ) is exhausted. The job is then time-slice (quantum put at the end of the ready queue if not yet completed. The critical issue with the RR policy is the length of the quantum. If it is too short, then the CPU will be spending more time on context switching. Otherwise, interactive processes will suffer.

Priority Each process is assigned a priority. The ready list contains an entry for each process ordered by its priority. The process at the beginning of the list (highest priority) is picked first. A variation of this scheme allows preemption of the current process when a higher priority process arrives. Another variation of the policy adds an aging scheme, where the priority of a process increases as it remains in the ready queue; hence, will eventually execute to completion.

Comparisons Unfortunately, the performance of scheduling policies vary substantially depending on the characteristics of the jobs entering the system (job mix), thus it is not practical to make definitive comparisons. For example, FCFS performs better for long processes and tends to favor CPU-bound jobs. Whereas SJF is risky, since long processes may suffer from CPU starvation. Furthermore, FCFS is not interactive jobs, and similarly, RR is not suitable for long batch jobs.

Deadlocks Deadlock - Occurs when resources needed by one process are held by some other waiting process. Deadlock not only occurs in OS. Kansas state legislature in the early 20th century passed the following legislation: "When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone. " Assume we have the following operating system: 1. Finite number of resources to be distributed among some number of competing processes 2. Resources may be of several types and there may be several instances of each

Deadlocks 3. When a process requests a resource any instance of that resource will satisfy the process 4. Processes can a. request a resource b. use the resource c. release the resource 5. A set of processes is in a deadlock state when every process in the set is waiting for an event that can be caused only by another process in the set. 1. Same resource type - three tape drives, three processes request a tape drive then they each request another. Dining philosophers request chopsticks held by another. 2. Different resource type - process A has a printer process B has a file, Each requests the other's resource.

Deadlocks Four Necessary Conditions for Deadlock 1. Mutual exclusion: At least one resource is not sharable, i.e. can only be used by one process at a time 2. Hold and wait: A process holds at least one resource and requests resources held by other processes 3. No preemption: resource cannot be preempted, it must be voluntarily released by the process. 4. Circular wait: Given a set of processes { P1, P2, P3, Pn} P1 has a resource needed by P2, P2 has a resource needed by P3,, Pn has a resource needed by P1.

Deadlock Avoidance Avoidance Deadlocks Provide information in advance about what resources will be needed by processes to guarantee that deadlock will not happen System only grants resource requests if it knows that the process can obtain all resources it needs in future requests Avoids circularities (wait dependencies) Tough Hard to determine all resources needed in advance Good theoretical problem, not as practical to use