Chapter 2 Processes and Threads 2.4 - 2.5 Scheduling Classical Problems.

Slides:



Advertisements
Similar presentations
Scheduling Introduction to Scheduling
Advertisements

CPU Scheduling Tanenbaum Ch 2.4 Silberchatz and Galvin Ch 5.
CS 149: Operating Systems February 3 Class Meeting
 Basic Concepts  Scheduling Criteria  Scheduling Algorithms.
Chapter 5 CPU Scheduling. CPU Scheduling Topics: Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
CPU Scheduling Section 2.5.
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Chapter 3: CPU Scheduling
© Ibrahim Korpeoglu Bilkent University
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Scheduling in Batch Systems
Project 2 – solution code
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
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.
1 Pertemuan 8 Penjadwalan (lanjutan) Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
1 Thursday, June 15, 2006 Confucius says: He who play in root, eventually kill tree.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
Chapter 2 Processes and Threads Scheduling Classical Problems.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
CPU Scheduling Chapter 6 Chapter 6.
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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
Processes and Threads.
1 Process States (1) Possible process states –running –blocked –ready Transitions between states shown.
Chapter 4 Processor Management
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.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Scheduling The part of the OS that makes the choice of which process to run next is called the scheduler and the algorithm it uses is called the scheduling.
Silberschatz and Galvin  Operating System Concepts Module 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor.
CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm.
2.5 Scheduling Given a multiprogramming system. Given a multiprogramming system. Many times when more than 1 process is waiting for the CPU (in the ready.
Operating Systems Scheduling. Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. Scheduling.
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.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
2.5 Scheduling. Given a multiprogramming system, there are many times when more than 1 process is waiting for the CPU (in the ready queue). Given a multiprogramming.
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.
CSC 322 Operating Systems Concepts Lecture - 10: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CS333 Intro to Operating Systems Jonathan Walpole.
1 ADVANCED OPERATING SYSTEMS Lecture 7 (Week 9) Resource Management – I (Process Scheduling) by: Syed Imtiaz Ali.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
操作系统原理 OPERATING SYSTEM Chapter 2 Processes and Threads 进程与线程.
Chapter 4 CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Algorithm Evaluation.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Basic Concepts Maximum CPU utilization obtained with multiprogramming
1 Lecture 5: CPU Scheduling Operating System Fall 2006.
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.
INTRO TO PROCESS SCHEDULING Module 2.4 COP4600 – Operating Systems Richard Newman.
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
Chapter 5a: CPU Scheduling
Chapter 2 Scheduling.
Chapter 6: CPU Scheduling
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 6: CPU Scheduling
Chapter 5: CPU Scheduling
Operating System Concepts
Chapter5: CPU Scheduling
Processes and Threads Part III
CPU SCHEDULING.
Presentation transcript:

Chapter 2 Processes and Threads Scheduling Classical Problems

Figure Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. Scheduling – Process Behavior Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Batch Interactive Real time Categories of Scheduling Algorithms Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure Some goals of the scheduling algorithm under different circumstances. Scheduling Algorithm Goals Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

First-come first-served Shortest job first Shortest remaining Time next Scheduling in Batch Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

First-Come First-Served Processes are assigned CPU in the order that they request it The process that is first in the queue gets as much time as it needs Subsequently added processes are placed behind it in the queue A single linked list keeps track of all ready processes Strength: easy to understand and implement Weakness: does not preempt processes

Shortest Job First Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Assumes run times are known in advance Scheduler puts the shortest job first First job takes A minutes, second takes A+B minutes Mean turnaround time is (4A + 3B + 2C +D)/4 Optimal only when all jobs are simultaneously available Ex: Run times: 2, 4, 1, 1, 1 Arrival times are 0, 0, 3, 3, 3 A B C D E = 4.6 sec average B C D E A = 4.4 sec average

Shortest Remaining Time Next Run time must be known in advance Chooses process whose remaining run time is the shortest When a new job arrives, its total time is compared to the remaining time of the currently running process. If the new job needs less time to finish than the current process, the current process is suspended and the new job is started

Round-robin scheduling Priority scheduling Multiple queues Shortest process next Guaranteed scheduling Lottery scheduling Fair-share scheduling Scheduling in Interactive Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Round-Robin Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Each job is assigned a time interval, called a quantum If the process is still running at the end of the quantum, the CPU is preempted and given to another process If the process finishes before the quantum has finished, the CPU switching is done when the process finishes Process switch: every time a quantum expires it takes a certain amount of time to switch to another process A longer quantum means that the preemption will not occur as often and most processes will finish before the quantum runs out

Priority Scheduling Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Each process is assigned a priority Process with highest priority is run first The scheduler may decrease the priority of the currently running process with each clock tick If the priority of a currently running process is lower than another process in the queue a process switch occurs Priority can be chosen by how important the user is, or how expensive the job is to run. Priorities can also be dynamically assigned Algorithm: 1/f, where f is fraction of the last quantum the process used Within a priority it is common to use round-robin to choose which job is run If priorities are not adjusted occasionally, lower priority classes may never be run

Multiple Queues Each priority class has its own amount of time to run Class 1 runs for 1 quantum, 2 for 2, 3 for 4, 4 for 8 … etc After each process uses up its quantum it is moved down one priority class Most systems give priority to interactive user processes over background ones To prevent a process from staying low priority forever, whenever the Enter key is pressed at the terminal, the current process is placed back up at the highest priority

Shortest Process Next SPN chooses the process whose remaining run-time is the shortest. –Example: The cashier in a store finds the person with the fewest items, and checks out their items first. SPN requires exact knowledge of how long a process will take in advance. If the mechanism to determine what is the shortest job is faulty then this might significantly reduce the throughput. If a system has a lot of short jobs and one long job then the long job may never run. SPN tends to be the most optimal scheduling system for total number of jobs completed short of Shortest Remaining Time (SRT). Can cause the halting problem.

Guaranteed Scheduling Makes promises about performance to the users/processes. Computes the real amount of CPU a user/processes has consumed. I.E. keeps track of how much CPU process has had since its creation. If there are n processes running on your pc, each process should get 1/n of the CPU cycles. –A ratio of.5 means that process has only had half of what it should have, and a ratio of 2.0 means that a process has had twice as much as it was entitled to. Runs the process with the lowest ratio until its ratio has moved above it’s closest competitor..

Lottery Scheduling Gives processes lottery tickets for various system resources (CPU time). When a scheduling decision is required a lottery ticket is randomly chosen and the process holding that ticket gets the resource. More important processes can be given extra tickets to increase odds of winning. Highly Responsive

Fair-Share Scheduling CPU usage is equally distributed among system users or groups, as opposed of equal distribution among processes. For example, if four users (A,B,C,D) are concurrently executing one process each, the scheduler will logically divide the available CPU cycles such that each user gets 25% of the whole (100% / 4 = 25%). If user B starts a second process, each user will still receive 25% of the total cycles, but both of user B's processes will now use 12.5%. On the other hand, if a new user starts a process on the system, the scheduler will reset the available CPU cycles such that each user gets 20% of the whole (100% / 5 = 20%).

Scheduling in Real-Time Systems In real time systems time plays a crucial role. Usually the system is connected to one or more external devices which generate stimuli and has to react appropriately to them within a fixed amount of time. –Examples: aircraft control, over-temperature monitor in nuclear power station, ABS, biomedical systems, robotics hard-real time - missing a deadline has catastrophic effects soft-real time - missing a deadline is undesirable but tolerable Stimuli (events) may be: –periodic (occurring at regular intervals) –aperiodic (unpredictable)

Schedualability Depending on the situation, it may happen that not all the events can be handled. Consider m periodic events – event i occurs with period Pi and requires Ci second of CPU time –The system is schedulable if:

Policy vs. Mechanism Often a process has many children running under its control performing different tasks. In this case only the process itself knows which one is the most important or time critical For this reason it is important to separate scheduling mechanism from the scheduling policy The scheduling mechanism (algorithm) defines the parameters used by the scheduler The user process is responsible for filling in those parameters for its children

Thread Scheduling Thread scheduler - part of the OS (usually) that is responsible for sharing the available CPUs out between the various threads. processes are typically independent, while threads exist as subsets of a process. User-level threads vs kernel level threads: - user-level thread maintains all its state in user space. - An advantage is that no kernel resources need to be allocated per thread, and switching between threads can be done without changing address space. - A disadvantage is that user level threads cannot execute while the kernel is busy, for instance, with paging or I/O. This would require some knowledge and participation on the part of the kernel.

Figure (a) Possible scheduling of user-level threads with a 50- msec process quantum and threads that run 5 msec per CPU burst. Thread Scheduling (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure (b) Possible scheduling of kernel-level threads with the same characteristics as (a). Thread Scheduling (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure Lunch time in the Philosophy Department. Dining Philosophers Problem (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure A nonsolution to the dining philosophers problem. Dining Philosophers Problem (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure A solution to the dining philosophers problem. Dining Philosophers Problem (3) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure A solution to the dining philosophers problem. Dining Philosophers Problem (4) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure A solution to the dining philosophers problem. Dining Philosophers Problem (5) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

See the video: Try it out for yourself: Dining Philosophers Problem (6) See the video: Try it out for yourself:

Figure A solution to the readers and writers problem. The Readers and Writers Problem (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Figure A solution to the readers and writers problem. The Readers and Writers Problem (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved