What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Similar documents
What s an Operating System? Real-Time Operating Systems. Cyclic Executive. Do I Need One? Handling an Interrupt. Interrupts


OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

Systemy RT i embedded Wykład 11 Systemy RTOS

Introduction to Real-Time Operating Systems

Multiprocessor and Real- Time Scheduling. Chapter 10

Tasks. Task Implementation and management

Chapter 5: CPU Scheduling

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

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

Process- Concept &Process Scheduling OPERATING SYSTEMS

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

Operating System Concepts Ch. 5: Scheduling

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Unit 3 : Process Management

Multiprocessor and Real-Time Scheduling. Chapter 10

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

Course Syllabus. Operating Systems

(b) External fragmentation can happen in a virtual memory paging system.

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

Frequently asked questions from the previous class survey

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

6/17/2011. Real-time Operating Systems

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

Process Scheduling Part 2

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

Module 1. Introduction:

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

Computer Systems Assignment 4: Scheduling and I/O

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

Operating Systems (1DT020 & 1TT802)

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Multimedia Systems 2011/2012

SMD149 - Operating Systems

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

NuttX Realtime Programming

CS3733: Operating Systems

Scheduling. The Basics

Scheduling of processes

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)

8th Slide Set Operating Systems

Real-Time Programming

Operating Systems. Scheduling

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

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

Concurrent activities in daily life. Real world exposed programs. Scheduling of programs. Tasks in engine system. Engine system

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

Analyzing Real-Time Systems

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

Operating System Review Part

8: Scheduling. Scheduling. Mark Handley

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

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

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

CSE 120 Principles of Operating Systems Spring 2017

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

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

CSE 120 Principles of Operating Systems

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

CS418 Operating Systems

RTOS Real T i Time me Operating System System Concepts Part 2

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)

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

ECE519 Advanced Operating Systems

Operating Systems. Process scheduling. Thomas Ropars.

PROCESSES & THREADS. Charles Abzug, Ph.D. Department of Computer Science James Madison University Harrisonburg, VA Charles Abzug

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

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)

Main Points of the Computer Organization and System Software Module

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

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

Timers 1 / 46. Jiffies. Potent and Evil Magic

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

CS 153 Design of Operating Systems Winter 2016

CHAPTER NO - 1 : Introduction:

CPU Scheduling Algorithms

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

Scheduling. CSC400 - Operating Systems. 7: Scheduling. J. Sumey. one of the main tasks of an OS. the scheduler / dispatcher

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Properties of Processes

Suggested Solutions (Midterm Exam October 27, 2005)

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Advanced Operating Systems (CS 202) Scheduling (1)

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

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

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

2. The system of... generally ran one job at a time. These were called single stream batch processing.

Embedded Systems. 6. Real-Time Operating Systems

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

Multiprocessor scheduling

OPERATING SYSTEM. Functions of Operating System:

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

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

Chapter 2 Processes and Threads

1.1 CPU I/O Burst Cycle

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

Transcription:

What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an OS? Not always Simplest approach: cyclic executive loop do part of task 1 do part of task 2 do part of task 3 end loop Cyclic Executive Advantages Simple implementation Low overhead Very predictable Disadvantages Can t handle sporadic events Everything must operate in lockstep Code must be scheduled manually Interrupts Some events can t wait for next loop iteration communication channels transient events A solution: Cyclic executive plus interrupt routines Interrupt: environmental event that demands attention example: byte arrived interrupt on serial channel Interrupt routine: piece of code executed in response to an interrupt Most interrupt routines: copy peripheral data into a buffer indicate to other code that data has arrived acknowledge the interrupt (tell hardware) longer reaction to interrupt performed outside interrupt routine e.g., causes a process to start or resume running 1

Handling An Interrupt 1. Normal program execution 2. Interrupt occurs 3. Processor state saved 4. Interrupt routine runs 7. Normal program execution resumes 6. Processor state restored 5. Interrupt routine terminates Cyclic Executive Plus Interrupts Works fine for many signal processing applications 56001 has direct hardware support for this style Insanely cheap, predictable interrupt handler: when interrupt occurs, execute a single user-specified instruction this typically copies peripheral data into a circular buffer no context switch, no environment save, no delay Drawbacks: main loop still running in lockstep programmer responsible for scheduling scheduling static sporadic events handled slowly Cooperative Multitasking A cheap alternative Non-preemptive Processes responsible for relinquishing control Examples: original Windows, Macintosh A process had to periodically call get_next_event() to let other processes proceed OS responsible for deciding which task to run next Drawbacks: programmer had to ensure this was called frequently an errant program would lock up the whole system Alternative: preemptive multitasking 2

Cooperative Multitasking void main() { Event e; while ((e=get_next_event())!= QUIT) { switch (e) { case CLICK: /*... */ break; } case DRAG: /*... */ break; case DOUBLECLICK: /*... */ break; case KEYDOWN: /*... */ break; /*... */ } } Concurrency Provided By OS Basic philosophy: Let the operating system handle scheduling, and let the programmer handle function Scheduling and function usually orthogonal Changing the algorithm would require a change in scheduling Batch Operating Systems Original computers ran in batch mode: submit job & its input job runs to completion collect output submit next job Processor cycles very expensive at the time Jobs involved reading, writing data to/from tapes Cycles were being spent waiting for the tape! 3

Timesharing Operating Systems Solution store multiple batch jobs in memory at once when one is waiting for the tape, run the other one Basic idea of timesharing systems Fairness primary goal of timesharing schedulers let no one process consume all the resources make sure every process gets equal running time Preemptive multitasking: give OS power to interrupt process programmer freed from scheduling scheduler can enforce fairness Real-Time Operating Systems Def: A real-time operating system is an operating system that supports the construction of real-time systems Main goal of an RTOS scheduler: meeting deadlines If you have five homework assignments and only one is due in an hour, you work on that one Fairness does not help you meet deadlines Real-Time Operating Systems The following are the three key requirements 1. The timing behavior of the OS must be predictable. services of the OS: Upper bound on the execution time! An RTOS must be deterministic: unlike standard Java, short times during which interrupts are disabled, contiguous files to avoid unpredictable head movements. 2. OS must manage the timing and scheduling OS possibly has to be aware of task deadlines; (unless scheduling is done off-line). OS must provide precise time services with high resolution. 3. The OS must be fast Practically important. 4

Real-Time Operating Systems attributes virtual memory application prog. scheduling policy I/O processing delivery of massive data between tasks resource allocation file system or disk RTOS none single purpose based on priority by app. prog. speed up by passing pointers, etc. static none or limited conventional OS yes general purpose fairness through drivers use system service like pipe, mailbox dynamic (runtime) yes Real-Time Operating Systems The basic guiding concept for most operating systems and schedulers is to strive for good average performance while in real time systems meeting the deadlines is far more important than average performance. Protected memory: while important for the stability of the system it carries a high overhead in a real time environment because of the added cost to a context switch and the caches that need to be flushed each context switch (the TLB for example). User and kernel modes: while protecting the systems from user processes adds significant overhead because each mode switch incurs a performance penalty because of the trap instructions and cache flushes. Memory paging: can increase the cost of a context switch by several magnitudes if the memory pages we need were switched out. This causes a lot of unpredictability in the timing. Dynamic memory allocation: this is a critical feature used by most modern application, however it creates memory fragmentation and as a result adds to timing unpredictability. Priority-Based Scheduler Typical RTOS based on fixed-priority preemptive scheduler Assign each process a priority At any time, scheduler runs highest priority process ready to run Process runs to completion unless preempted 5

Priority-Based Preemptive Scheduling Always run the highest-priority runnable process 1 2 3 Priority-Based Preemptive Scheduling Multiple processes at the same priority level? A few solutions simply prohibit: Each process has unique priority time-slice processes at the same priority extra context-switch overhead no starvation dangers at that level processes at the same priority never preempt the other more efficient still meets deadlines if possible Priority Inversion RMS and EDF assume no process interaction Often a gross oversimplification Consider the following scenario: 1 2 Process 1 tries to acquire lock for resource Process 1 preempts Process 2 Process 2 acquires lock on resource Process 2 begins running 6

Tasks Tasks tasks and task control block (TCB) task ID starting address task context (PC, SP, registers, etc) task parameters scheduling information synchronization information timer information other information task parameters for real-time OS task type phase period relative deadline priority release time loss rates Tasks Real-Time Tasks Task scheduling inserted into the schedule queue when ready scheduling policies, scheduling disciplines non-real-time FCFS, round robin, priority-based, shortest job first, etc. real-time rate monotonic, earliest deadline first, etc. priority assignment criteria importance(criticality), period, deadline execution time, arrival time, elapsed time after ready method dynamic (at runtime) static (at initialization) 7

Kernel Kernel Kernel performs basic functions for task management and intertask communication usually, resident in main memory Non-preemptive kernel once executed on CPU, a task continues executing until it releases control in case of interrupt, it resumes execution upon completion of ISR advantages completion time of task execution is predictable (if execution time of ISR is negligible) no dynamic interference of data between tasks disadvantages high priority tasks may be blocked unnecessarily schedulability test difficult low responsiveness Non-Preemptive Kernel interrupt ISR makes the high priority task ready. TL terminates and relinquishes the CPU. 8

RTOS Preemptive kernel upon transition to ready state, a high priority task will be dispatched by suspending lower priority task in execution in case of interrupt, a higher priority task will be scheduled upon completion of ISR advantage higher priority task: predictable completion time real-time responsiveness disadvantage conflict in using shared data and resources Preemptive Kernel interrupt ISR makes the high priority task ready. Synchronization Mutual exclusion shared data resides in the same address space e.g.: global variables, pointers, buffers, lists access through critical sections inter-task communication using shared data concurrent accesses must be controlled to avoid corrupting the shared data mutual exclusion mutual exclusion techniques disabling interrupts test-and-set operation disabling the scheduler semaphores 9

Memory Usage programs (executable codes) task control block, TCB stack space 10