OVERVIEW. Last Week: But if frequency of high priority task increases temporarily, system may encounter overload: Today: Slide 1. Slide 3.

Similar documents
LAST LECTURE ROUND-ROBIN 1 PRIORITIES. Performance of round-robin scheduling: Scheduling Algorithms: Slide 3. Slide 1. quantum=1:

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

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

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

Course Syllabus. Operating Systems

Operating Systems. Scheduling

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

Roadmap for This Lecture

RT extensions/applications of general-purpose OSs

8: Scheduling. Scheduling. Mark Handley

Comparison of scheduling in RTLinux and QNX. Andreas Lindqvist, Tommy Persson,

REAL-TIME OPERATING SYSTEMS SHORT OVERVIEW

Two Real-Time Operating Systems and Their Scheduling Algorithms: QNX vs. RTLinux

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Chapter 5: CPU Scheduling

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

Multiprocessor and Real-Time Scheduling. Chapter 10

Real-Time Systems. Real-Time Operating Systems

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

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

Scheduling (Win 2K) CSE Computer Systems November 21, 2001

CS370 Operating Systems

Department of Computer Science Institute for System Architecture, Operating Systems Group REAL-TIME MICHAEL ROITZSCH OVERVIEW

Real-Time Systems Hermann Härtig Real-Time Operating Systems Brief Overview

Process- Concept &Process Scheduling OPERATING SYSTEMS

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

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)

Multiprocessor and Real- Time Scheduling. Chapter 10

Learning Outcomes. Scheduling. Is scheduling important? What is Scheduling? Application Behaviour. Is scheduling important?

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)

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: Objectives

Case Study. Windows XP. Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

Scheduling. Scheduling 1/51

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

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Scheduling - Overview

Commercial Real-time Operating Systems An Introduction. Swaminathan Sivasubramanian Dependable Computing & Networking Laboratory

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

Scheduling. Scheduling 1/51

Round Robin (RR) ACSC 271 Operating Systems. RR Example. RR Scheduling. Lecture 9: Scheduling Algorithms

EECS 571 Principles of Real-Time Embedded Systems. Lecture Note #10: More on Scheduling and Introduction of Real-Time OS

This slide show uses materials from the Windows Operating System Internals Curriculum Development Kit

CS370 Operating Systems

CS 326: Operating Systems. CPU Scheduling. Lecture 6

Computer Systems Assignment 4: Scheduling and I/O

CSI3131 Final Exam Review

Process Scheduling Queues

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Scheduling in the Supermarket

CS370 Operating Systems

PROCESS SCHEDULING Operating Systems Design Euiseong Seo

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

Outline. Process and Thread Management. Data Structures (2) Data Structures. Kernel Process Block (PCB)

Process and Thread Management

Operating Systems CS 323 Ms. Ines Abbes

CS307: Operating Systems

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

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

Microkernel Construction

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Interactive Scheduling

Two Level Scheduling. Interactive Scheduling. Our Earlier Example. Round Robin Scheduling. Round Robin Schedule. Round Robin Schedule

Multiprocessor System. Multiprocessor Systems. Bus Based UMA. Types of Multiprocessors (MPs) Cache Consistency. Bus Based UMA. Chapter 8, 8.

Multiprocessor Systems. COMP s1

SMD149 - Operating Systems

Module 23: Windows NT. Windows NT

Introduction. CS3026 Operating Systems Lecture 01

Module 23: Windows NT

Chapter 5: Process Scheduling

Chapter 5: CPU Scheduling

238P: Operating Systems. Lecture 14: Process scheduling

Virtual Memory Management

Zilog Real-Time Kernel

Operating System Concepts Ch. 5: Scheduling

VEOS high level design. Revision 2.1 NEC

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

Processes and Threads

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

Last Class: Processes

CS2506 Quick Revision

Frequently asked questions from the previous class survey

CHAPTER 2: PROCESS MANAGEMENT

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

The control of I/O devices is a major concern for OS designers

Following are a few basic questions that cover the essentials of OS:

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

* There are more than 100 hundred commercial RTOS with memory footprints from few hundred kilobytes to large multiprocessor systems

Scheduling. CS 161: Lecture 4 2/9/17

Comparison of soft real-time CPU scheduling in Linux kernel 2.6 series with Solaris 10

Embedded Systems. 6. Real-Time Operating Systems

Properties of Processes

CS A331 Programming Language Concepts

Real-Time Programming

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

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)

Chapter 5: CPU Scheduling

ZiLOG Real-Time Kernel Version 1.2.0

Transcription:

OVERVIEW Last Week: Scheduling Algorithms Real-time systems Today: But if frequency of high priority task increases temporarily, system may encounter overload: Yet another real-time scheduling algorithm Slide 1 Case studies Changes in the Linux kernel Real-time operating systems Windows 2000: Scheduling, VM Slide 3 - system not able to respond Overview - system may not be able to perform requested service Next Week: Q & A session: send me a list of topics you would like me to explain again Problem: Example: (from Scheduling Sporadic Events, Lonni Vanzandt) in real life applications, many tasks are not always periodic. Network interface control driver, requirements: static priorities may not work avoid if possible to drop packets Slide 2 If real time threads run periodically with same length, fixed priority is no problem: a a a a a a a b b b b b b b Slide 4 definitely avoid overload If receiver thread get highest priority permanently, system may go into overload if incoming rate exceeds a certain value. expected frequency: packet once every 64µs CPU time required to process packet: 25µs 32-entry ring buffer, max 50% full - a: periodic real time thread, highest priority - b: periodic real time thread - various different low priority tasks (e.g., user I/O) packet every 64µs receiver thread 25µs/packet OVERVIEW 1 SPORADIC SCHEDULING 2

Example: Slide 5 POSIX standard to handle aperiodic or sporadic events SPORADIC SCHEDULING with static priority, preemptive scheduler Implemented in hard real-time systems such as QNX, some real-time versions of Linux, real-time specification for Java (RTSJ)(partially) Can be used to avoid overloading in a system Slide 7 execution budget: 5 replenishment interval: 13 Thread does not block: 5 budget replenishment interval 5 10 15 time Thread blocks: Basic Idea: simulation of periodic behaviour of thread by assigning 5 realtime priority: P r budget replenishment interval Slide 6 background priority: P b execution budget: E replenishment interval: R to thread. Whenever thread exhausts execution budget, priority is set to background priority P b When thread blocks after n units, n will be added to execution budget R units after execution started When execution budget is incremented, thread priority is reset to P r Slide 8 replenishment interval 5 10 15 20 time (0) exection starts, 1st replenishment interval starts (3) thread blocks (5) continues execution, 2nd replenishment interval starts (7) budget exhausted (13) budget set to 3, thread continues execution (16) budget exhausted (18) budget set to 2 (19) thread continues execution SPORADIC SCHEDULING 3 SPORADIC SCHEDULING 4

Example: Network interface control Driver use expected incoming rate and desired max CPU utilisation of thread to compute execution budget and replenishment period if no other threads wait for execution, packets can be processed even if load is higher Scheduling: REAL-TIME SUPPORT IN LINUX 2.4. otherwise, packets may be dropped - POSIX SCHED FIFO, SCHED RR, Slide 9 packet every 64µs receiver thread 25µs/packet Slide 11 Virtual Memory: - no VM for real-time apps - mlock() and mlockall() to switch off paging (which other applications might need to do this?) period: 64µs * 16 = 1024µs Timer: resolution: 10ms, too coarse grained for real-time apps execution time: 25µs * 16 = 400µs CPU load caused by receiver thread: 400/1024 = 0.39, about 39% HARD REAL TIME OS IMPROVEMENTS IN 2.6 KERNEL We look at examples of three types of systems: Kernel Preemption Slide 10 real-time support in a general purpose operating system configurable hard real time systems system designed as real time OS from the start hard real-time variants of general purpose OSs try to alleviate shortcomings of OS with respect to real time apps Slide 12 kernel code laced with preemption points calling process can block and thereby yield CPU to higher-priority process Kernel can be built without VM Improved scheduler Timer resolution: 1ms REAL-TIME SUPPORT IN LINUX 2.4. 5 SCHEDULING IN 2.4 AND 2.6: COMPARISON 6

SCHEDULING IN 2.4 AND 2.6: COMPARISON Slide 13 2.4: CPU time divided into epochs Each process has a (poss. different) time quantum it is allowed to run in every epoch Epoch ends when all runnable processes have exhausted their quantum Time quantum for each process recomputed after every epoch To find the next process which should be scheduled, the complete ready-queue has to be scanned SMP: only single ready-queue Slide 15 RTLINUX abstract machine layer between actual hardware and Linux kernel takes control of - hardware interrupts - timer hardware - interrupt disable mechanism real time scheduler runs with no interference fron Linux kernel programmer must utilise RTLinux API for real time applications O(n) algorithm: overhead grows linearly with number of PE s Ready queue access bottle neck for SMP Slide 14 2.6: Queue for each priority Thread can be in active (quantum not yet expired) or expired (quantum already used up) queue. Priority is re-calculated after quantum is expired Interactive processes inserted back into active-queue SMP: One set of queue per processor, idle processors steal work from other processors O(1) algorithm: time required for scheduling decision does not depend on number of processes Slide 16 QNX Microkernel based architecture POSIX standard API Modular can be costumised for very small size (eg, embedded systems) or large systems Memory protection for user applications and os components Scheduling: FIFO scheduling Round-robin Adaptive scheduling Ready queue access not a bottle neck for SMP Better locality - thread consumes its timeslice, its priority is reduced by one - thread blocks, it immediately comes back to its base priority POSIX sporadic scheduling RTLINUX 7 QNX 8

Slide 17 Kernel Services: Thread services: provides the POSIX thread creation primitives. Signal services: provides the POSIX signal primitives. Message passing services: handles the routing of all messages between all threads through the whole system. Synchronization services: provides the POSIX thread synchronization primitives. Scheduling services: schedules threads using the various POSIX realtime scheduling algorithms. Timers services: provides the set of POSIX timer. Slide 19 WINDOWS CE 5.0 Componentised OS designed for embedded systems with hard real-time support handles nested interrupts handles priority inversion based on priority inheritance Offers guaranteed upper bound on high priority thread scheduling guaranteed upper bound on delay for interrupt service routines Process Manager: Slide 18 The process manager is capable of creating multiple POSIX processes (each of which may contain multiples POSIX threads). Its main areas of responsability include: Process management: manages process creation, destruction, and process attributes such us user ID and group ID. Memory management: manages memory protection, shared libraries, and POSIX shared memory primitives. Pathname management: manages the pathname space (mountpoints). Slide 20 Scheduling WINDOWS 2000 CASE STUDY Virtual Memory Management WINDOWS CE 5.0 9 WINDOWS 2000 SCHEDULING 10

WINDOWS 2000 SCHEDULING priority driven, preemptive scheduling system SMP: set of processors a thread can run on may be restricted (processor affinity) Slide 21 scheduling decision may be necessary when a new thread has been created a thread released from wait state Slide 23 if thread with higher priority becomes ready to run, current thread is preempted scheduled at thread granularity time quantum of a thread is exceeded a thread s priority changes processes with many threads get more CPU time processor affinity of a thread changes no dedicated scheduler thread each thread chooses successor while running in kernel mode WINDOWS 2000 SCHEDULING Job Windows 2000 priority levels: 0 (zero- thread) 1-15 (variable levels) 16-31 (realtime levels soft) Slide 22 Address space Process handle table Thread User stack Process Kernel mode thread stack P T T Access token T T P Slide 24 Win32 API priority classes: Real-time High Above Normal Normal Below Normal Idle and relative priorities within these classes: Time-critical High... WINDOWS 2000 SCHEDULING 11 WINDOWS 2000 SCHEDULING 12

Slide 25 each thread has a quantum value, clock-interrupt handler deducts 3 from running thread quantum default value of quantum: 6 Windows 2000 Professional, 36 on Windows 2000 Server most wait-operations result in temporary priority boost, favouring IO-bound threads priority of a user thread can be raised (eg, after waiting for a semaphore etc), but never above 15 no adjustments to priorities above 15 Slide 26 Win32 process class priorities Above Below Realtime High Normal Normal Normal Idle Time critical 31 15 15 15 15 15 Highest 26 15 12 10 8 6 Win32 Above normal 25 14 11 9 7 5 thread Normal 24 13 10 8 6 4 priorities Below normal 23 12 9 7 5 3 Lowest 22 11 8 6 4 2 Idle 16 1 1 1 1 1 WINDOWS 2000 SCHEDULING 13 Priority 31 Next thread to run System priorities 24 Slide 27 16 User priorities 8 Zero thread 1 0 Idle thread DEALING WITH PRIORITY INVERSION IN WINDOWS 2000 Example: Producer-Consumer problem 12 Blocked 12 Does a down on the semaphore and blocks Waiting on the semaphore Slide 28 Semaphone Running 8 Semaphone Ready 4 Would like to do an up on the semaphore but never gets scheduled (a) (b) System keeps track of how long a ready-thread has been in the queue if waiting time exceeds threshold, priority boosted to 15 MEMORY MANAGEMENT 14

MEMORY MANAGEMENT Every process has 4GB virtual address space Process A Process B Process C 4 GB Nond pool Paged pool Nond pool Paged pool Nond pool Paged pool Slide 29 2 GB A's tables Stacks, data, etc HAL + OS System data B's tables Stacks, data, etc HAL + OS System data C's tables Stacks, data, etc HAL + OS System data Process A's private code and data Process B's private code and data Process C's private code and data 0 Bottom and top 64 KB are invalid MEMORY MANAGEMENT A can be in one of three states: Slide 30 free: not in use, reference to such a causes a fault committed: data or code mapped onto the. If not in main memory, fault occurs, OS swaps from disk reserved: not yet mapped, but also not available. Used, for example, to implement thread stacks and has the usual readable, writable, executable attributes MEMORY MAPPED FILES 15 MEMORY MAPPED FILES memory mapped filed supported processes may share maps, updates visible to all processes if file is opened for normal reading, current version is shown copy-on-write (cow) Backing store on disk Slide 31 Process A Process B Stack Stack Region Data Paging file Data Shared library Lib.dll Shared library Program Program Prog1.exe Prog2.exe WIN32 API FOR VM Slide 32 Win32 API function Description VirtualAlloc Reserve or commit a region VirtualFree Release or decommit a region VirtualProtect Change the read/write/execute protection on a region VirtualQuery Inquire about the status of a region VirtualLock Make a region memory resident (i.e., disable paging for it) VirtualUnlock Make a region able in the usual way CreateFileMapping Create a file mapping object and (optionally) assign it a name MapViewOfFile Map (part of) a file into the address space UnmapViewOfFile Remove a mapped file from the address space OpenFileMapping Open a previously created file mapping object MEMORY MANAGEMENT 16

MEMORY MANAGEMENT DAEMON THREADS TO MANAGE WORKING SETS Slide 33 Unlike scheduler, who deals with threads and ignores processes, MM deals only with processes Mapping of s happens in the usual way, two-level table used In case of a fault, a block of consecutive s are read Slide 35 Balance Set Manager: checks whether there are enough free s, starts Working Set Manager if required Working Set Manager: searches for processes which have exceeded their maximum, didn t have faults recently and removes some of their s Working Set: PAGE REPLACEMENT ALGORITHM A closer look at the free frames management: Page read in (6) Zero needed (8) Slide 34 set of s of a process which have been mapped into memory described by (process specific) max and min size all processes start with the same limits, but may change over time not hard bounds if fault occurs and process has less than min s: add between min and max s: add if memory is not scarce more than max s: evict from working set Working set of system is handled separately. Slide 36 Working sets Soft fault (2) Top Bottom Mod- ified list Modified writer(4) Standby list Dealloc(5) Free list Page evicted from a working set (1) Process exist (3) Zero thread (7) Zeroed list There are actually four separate lists which contain free frames ➀ Modified Pages ➁ Standby Pages ➂ Free Pages ➃ Zeroed Pages Bad RAM list DAEMON THREADS TO MANAGE WORKING SETS 17 DAEMON THREADS TO MANAGE WORKING SETS 18

A closer look at the free frames management: Page frame database State Cnt WS Other PT Next Page tables Slide 37 List headers Standby Modified Free Zeroed 14 13 12 11 Clean Dirty Clean Active 20 10 9 8 Clean Dirty Active 4 7 6 5 4 3 Dirty Free Free Zeroed Active 6 2 1 Zeroed Active 14 0 Zeroed X X X X DAEMON THREADS TO MANAGE WORKING SETS 19