OPERATING SYSTEMS 9 – SCHEDULING PIETER HARTEL 1.

Slides:



Advertisements
Similar presentations
Operating Systems Process Scheduling (Ch 3.2, )
Advertisements

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
Operating System Process Scheduling (Ch 4.2, )
Operating System I Process Scheduling. Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which.
CS 311 – Lecture 23 Outline Kernel – Process subsystem Process scheduling Scheduling algorithms User mode and kernel mode Lecture 231CS Operating.
Scheduling. Unix Scheduling Allocating CPU to a Process The amount of time that a process is allocated the CPU is called a time quantum Processes are.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Operating Systems Process Scheduling (Ch 4.2, )
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
Operating System Process Scheduling (Ch 4.2, )
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Main Job: Assign processes to be executed by the processor(s) and processes to be loaded in main.
Uniprocessor Scheduling
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria 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: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
CPU Scheduling Chapter 6 Chapter 6.
Process Scheduling Decide which process should run and for how long Policy: Maximize CPU utilization Mechanism:Multiprogramming Dispatch latency Time required.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Chapter 9 Uniprocessor Scheduling Spring, 2011 School of Computer Science & Engineering Chung-Ang University.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling To improve: Response time: time it takes a system to react to a given input Turnaround Time (TAT)
Alternating Sequence of CPU And I/O Bursts. Histogram of CPU-burst Times.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 7: CPU Scheduling Chapter 5.
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling
Uniprocessor Scheduling Chapter 9. Processor Scheduling Processor scheduling determines the assignment of processes to be executed by the processor over.
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
ITFN 2601 Introduction to Operating Systems Lecture 4 Scheduling.
OPERATING SYSTEMS 1 - HARDWARE PIETER HARTEL 1. Hardware 2.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
OPERATING SYSTEMS 3 - PROCESSES PIETER HARTEL 1. Principle of concurrency - giving a process the illusion that it owns the whole machine  A process has:
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
1 Module 5: Scheduling CPU Scheduling Scheduling Algorithms Reading: Chapter
1 Chapter 5: CPU Scheduling. 2 Basic Concepts Scheduling Criteria Scheduling Algorithms.
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
CPU SCHEDULING.
Uniprocessor Scheduling
Chapter 5: CPU Scheduling
Operating Systems 9 – scheduling
Uniprocessor Scheduling
Uniprocessor Scheduling
Chapter 2.2 : Process Scheduling
Process Scheduling B.Ramamurthy 9/16/2018.
Chapter 5: CPU Scheduling
Process management Information maintained by OS for process management
Chapter 5: CPU Scheduling
Chapter 5: CPU Scheduling
OverView of Scheduling
Operating System Concepts
TDC 311 Process Scheduling.
Chapter 9 Uniprocessor Scheduling
Process Scheduling Decide which process should run and for how long
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Process Scheduling B.Ramamurthy 4/7/2019.
Process Scheduling B.Ramamurthy 4/19/2019.
Process Scheduling B.Ramamurthy 4/24/2019.
Topic 5 (Textbook - Chapter 6) CPU Scheduling
Chapter 5: CPU Scheduling
Scheduling 21 May 2019.
Uniprocessor Scheduling
Presentation transcript:

OPERATING SYSTEMS 9 – SCHEDULING PIETER HARTEL 1

Types of scheduling  Short-term: which runnable process to handle by which CPU  Medium-term: which processes to swap in (challenge?)  Long-term: which processes to accept in a batch environment  I/O scheduling: which pending I/O request to handle by which I/O device 2

Scheduling is managing queues to minimise delays  User oriented criteria: response time, deadlines, predictability  System oriented criteria: throughput, resource utilisation  Tension?  Events include? 3

Common scheduling policies  Round robin requires pre-emption, quantum can be varied  Example arrival&service times: A: 0&3; B: 2&6; C: 4&4; D: 6&5; E: 8&2 4

Multi-level feedback queue : past behaviour predicts future  Round Robin in RQ i for 2 i time units  Promote waiting processes  Demote running processes 5

Linux scheduling (section 10.3)  Three levels  Real-time FIFO, pre-empted only by higher priority RT FIFO  Round robin, pre-empted by clock after quantum expiry  Time sharing, lower priority, otherwise as above  Completely Fair Scheduling 6

#include "loop.h" #define M 1690 /* Burn about N * 10 ms CPU time */ void loop(int N) { int i, j, k ; for(i = 0; i < N; i++) { for(j = 0; j < M; j++) { for(k = 0; k < M; k++) { } loop  gcc –c loop.c –o loop.o  Write a test program 7 #ifndef _loop_h #define _loop_h 1 extern void loop(int N) ; #endif loop.h loop.c

int main(int argc, char *argv[]) { pid_t pid = getpid(); struct sched_param param; param.sched_priority=Y; if( sched_setscheduler(pid, X, &param) != 0 ) { printf("cannot setscheduler\n"); } else { loop(100); }; return 0; } SchedXY  gcc –o RR80 loop.o -DX=SCHED_RR -DY=80 SchedXY.c  sudo./RR80&  top 8

#define N 8 #define M void *tproc(void *ptr) { int k, i = *((int *) ptr); int bgn = sched_getcpu(); printf("thread %d on CPU %d\n", i,bgn); for(k=0;k<M;k++) { int now = sched_getcpu(); if( bgn != now ) { printf("thread %d to CPU %d\n", i,now); break; } sched_yield(); } pthread_exit(0); } ThreadSched  Output?  gcc ThreadSched.c -lpthread ./a.out ./a.out xx 9

int main(int argc, char *argv[]) { int p, q, r; cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(1, &cpuset); sched_setaffinity(parent, sizeof(cpu_set_t), &cpuset); for( p = 0; p < P; p++ ) { for( q = 0; q < Q; q++ ) { pid_t child = fork(); if (child == 0) { setpriority(PRIO_PROCESS, getpid(), p) ; for(r = 0; r < R; r++) { loop(100); } exit(0) ; } Nice  Output?  gcc Nice.c loop.o ./a.out >junk&  top ./a.out ./a.out xx 10

Summary  Maximising resource usage, while minimising delays  Decisions  Long term: admission of processes  Medium term: swapping  Short term: CPU assignment to ready process  Criteria  Response time: users  Throughput: system 11