Preemptive Minithreads Tom Roeder CS415 2005sp. Multi-level Feedback Queues Quantum = 2 Quantum = 4 Quantum = 8 Quantum = 16 Lowest priority Highest priority.

Slides:



Advertisements
Similar presentations
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
CPU Scheduling Questions answered in this lecture: What is scheduling vs. allocation? What is preemptive vs. non-preemptive scheduling? What are FCFS,
1 Uniprocessor Scheduling Types of scheduling –The aim of processor scheduling is to assign processes to be executed by the processor so as to optimize.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 17 Scheduling III.
A. Frank - P. Weisberg Operating Systems Advanced CPU Scheduling.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
Operating Systems 1 K. Salah Module 2.1: CPU Scheduling Scheduling Types Scheduling Criteria Scheduling Algorithms Performance Evaluation.
Project 2 – solution code
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (2) Process Management 10/03/2008 Yang Song (Prepared by Yang Song and.
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
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.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads and Scheduling 6.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
Project Part I Background Tom Roeder CS sp.
Operating System Process Scheduling (Ch 4.2, )
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues.
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
Uniprocessor Scheduling
Chapter 5: CPU Scheduling (Continuation). 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Determining Length.
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.
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.
CSC 360- Instructor: K. Wu CPU Scheduling. CSC 360- Instructor: K. Wu Agenda 1.What is CPU scheduling? 2.CPU burst distribution 3.CPU scheduler and dispatcher.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
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,
Chapter 6 CPU SCHEDULING.
1 Scheduling Processes. 2 Processes Each process has state, that includes its text and data, procedure call stack, etc. This state resides in memory.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
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.
1 Our focus  scheduling a single CPU among all the processes in the system  Key Criteria: Maximize CPU utilization Maximize throughput Minimize waiting.
Chapter 5 CPU Scheduling Bernard Chen Spring 2007.
CPU Scheduling CS 6560: Operating Systems Design.
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
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
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
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,
Lecture 4 CPU scheduling. Basic Concepts Single Process  one process at a time Maximum CPU utilization obtained with multiprogramming CPU idle :waiting.
CPU Scheduling CS Introduction to Operating Systems.
CPU scheduling.  Single Process  one process at a time  Maximum CPU utilization obtained with multiprogramming  CPU idle :waiting time is wasted 2.
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
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.
UNIT–II: Process Management
Project 2: Preemption CS 4411 Spring 2017
Networks and Operating Systems: Exercise Session 2
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 9 Uniprocessor Scheduling
CPU SCHEDULING.
CPU scheduling decisions may take place when a process:
Process Scheduling Decide which process should run and for how long
Uniprocessor scheduling
Shortest-Job-First (SJR) Scheduling
CSE 153 Design of Operating Systems Winter 2019
Don Porter Portions courtesy Emmett Witchel
Presentation transcript:

Preemptive Minithreads Tom Roeder CS sp

Multi-level Feedback Queues Quantum = 2 Quantum = 4 Quantum = 8 Quantum = 16 Lowest priority Highest priority Borrowed from 414 notes

Multi-level Queues Just like a regular queue, except  4 levels: can insert into any one  If a dequeue is requested and there’s no element on this level, try the next. Return which level.  returns NULL and -1 if the are no elements Note: errors inside the queues should cause an exit We will use this data structure for scheduling You will want to reuse your queue impl

Our Scheduling Algorithm Feedback Queues:  4 levels with quantum doubling at each  demotion: if thread overruns its quantum ie. thread has not yielded before preemption will happen frequently for CPU-bound procs  promotion: by age assign points upon queue entry points accumulate over time we add a promotion threshold

Algorithm Comparisons Our alg: starvation elimination Tries to get SRTF scheduling  current level: function of age and past CPU bursts  thus we are averaging CPU bursts over age other options  no promotions many jobs float to the bottom very predictable poor waiting time and latency

Algorithm Comparisons other options (cont’d)  weighted levels always work with all levels, but visit lower ones rarely assign weights to each level: 50%, 25%, 15%, 10% still no promotion, so all past history matters!  burst measurements for promotions little real history  need to add a weighted averaging to be realistic  otherwise very unpredictable, jittery

Interrupts On minithread_clock_init, you will start receiving interrupts Right now just clock interrupts, but a general interrupt mechanism is present in the code  Network packets will later cause interrupts Happen on the current stack  Control is wrenched from the current thread  Given to clock handler Don’t waste time in the clock handler!

Clock Handler and Alarms When you receive a clock tick:  Don’t use system functions (too slow)  Just count the ticks in a variable Need a structure to keep track of alarms  Hint: you probably have already implemented one  A queue normally doesn’t provide fast search  This is OK, if you assume cancel infrequent Your clock handler will need to run the alarms  alarm functions must be short and not block!

Low-level synchronization Cannot block at interrupt time:  interrupts may interrupt our synch code  for short synchronization: disable interrupts interrupt_level_t intlevel = set_interrupt_level(DISABLED); /* your code here */ set_interrupt_level(intlevel); Don’t do this too much: hurts performance  will be penalized in grading

Warnings Do not block while interrupts are disabled Do not call system functions in a handler Interrupts may be called in any context Avoid disabling interrupts wherever possible  make any disabled period as short as possible Beware of nested disable/enable blocks Synchronize all global data!

How to get started First implement and test the multi-level Q  dequeue should always return a value if possible Then experiment with clock interrupts  slow them down (modify “interrupts.h” )  make sure a simple handler works Add alarms Change the scheduler  make sure round-robin works on a simple queue  add points and a multi-level queue  do demotion and promotion

Grading Correctness  avoid race conditions (eg. in alarm code)  nested interrupt level changes Efficiency  handlers must be fast  idle thread runs only when idle  don’t overdo interrupt disabling Good software engineering  clean design, good comments

Questions?