Process Scheduling Queues

Similar documents
Machines and Virtualization. Systems and Networks Jeff Chase Spring 2006

Memory Protection. Machines and Virtualization. Architectural Foundations of OS Kernels. Memory and the CPU. Introduction to Virtual Addressing

Traps and Faults. Review: Mode and Space

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Hardware OS & OS- Application interface

Processes and Threads. Processes and Threads. Processes (2) Processes (1)

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Computer Systems II. First Two Major Computer System Evolution Steps

Major Requirements of an OS

! The Process Control Block (PCB) " is included in the context,

Virtual Machines & the OS Kernel

Process Description and Control

Lecture 2: Architectural Support for OSes

Windows Interrupts

EE458 - Embedded Systems Exceptions and Interrupts

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Sistemi in Tempo Reale

Introduction Programmer Interface User Interface Process Management Memory Management File System I/O System Interprocess Communication

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

Process Description and Control. Chapter 3

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

ECE 650 Systems Programming & Engineering. Spring 2018

Virtual Machines & the OS Kernel

Virtual Machines & the OS Kernel

CSE 153 Design of Operating Systems Fall 18

Processes and Threads

Announcement. Exercise #2 will be out today. Due date is next Monday

3.1 Introduction. Computers perform operations concurrently

Process Description and Control. Chapter 3

Predictable Interrupt Management and Scheduling in the Composite Component-based System

The Kernel Abstraction

Lecture 15: I/O Devices & Drivers

Operating System. Chapter 4. Threads. Lynn Choi School of Electrical Engineering

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

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

Advanced Operating Systems (CS 202) Scheduling (1)

Uniprocessor Scheduling

CSE 153 Design of Operating Systems

The Kernel Abstraction. Chapter 2 OSPP Part I

CSCE Introduction to Computer Systems Spring 2019

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

The Big Picture So Far. Chapter 4: Processes

Operating Systemss and Multicore Programming (1DT089)

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

IT 540 Operating Systems ECE519 Advanced Operating Systems

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Lecture 5: Process Description and Control Multithreading Basics in Interprocess communication Introduction to multiprocessors

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)

CS370 Operating Systems

Process Description and Control. Chapter 3

Diagram of Process State Process Control Block (PCB)

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Operating System Concepts Ch. 5: Scheduling

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)

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

An Operating System in Action

Process Characteristics. Threads Chapter 4. Process Characteristics. Multithreading vs. Single threading

Threads Chapter 4. Reading: 4.1,4.4, 4.5

Process Description and Control. Major Requirements of an Operating System

Major Requirements of an Operating System Process Description and Control

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Lecture 2 Process Management

Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

Uniprocessor Scheduling. Aim of Scheduling

Uniprocessor Scheduling. Aim of Scheduling. Types of Scheduling. Long-Term Scheduling. Chapter 9. Response time Throughput Processor efficiency

SMD149 - Operating Systems

The Big Picture So Far. Chapter 4: Processes

Processes and Exceptions

Computer architecture. A simplified model

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

CSE 120 Principles of Operating Systems

Chapter 13: I/O Systems

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.

Chap 4, 5: Process. Dongkun Shin, SKKU

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

CSE 120 Principles of Operating Systems

CS510 Operating System Foundations. Jonathan Walpole

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

CSE 120 Principles of Operating Systems

Chapter 5: CPU Scheduling

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

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

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Process Description and Control

CSE398: Network Systems Design

OPERATING SYSTEM PROJECT: SOS

Operating System Kernel

CSE 451: Operating Systems Winter I/O System. Gary Kimura

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

Course: Operating Systems Instructor: M Umair. M Umair

Transcription:

Process Control

Process Scheduling Queues Job queue set of all processes in the system. Ready queue set of all processes residing in main memory, ready and waiting to execute. Device queues set of processes waiting for an I/O device. Process migration between the various queues. Q1 2

Ready Queue, I/O Device Queues 3

Process Scheduling 4

Schedulers Long term scheduler: job scheduler selects which processes should be brought into the ready queue. invoked infrequently (seconds, minutes) controls the degree of multiprogramming Medium term scheduler allocates memory for process. invoked periodically or as needed. Short term scheduler: CPU scheduler selects which process should be executed next and allocates CPU. invoked frequently (ms) Q2 5

Process Switching Definition The activity that occurs when the OS kernel switches between processes in an effort to share the CPU among competing, runable processes Actions Save contents of hardware registers (PC, SP,...) Load PC with location of resume point Load hardware registers with new context if full context switch 6

Process Switching Process switch time is overhead CPU utilization affected by quantum and process switch time Quantum: Time slice (max CPU interval) given to a process Time dependent on hardware support Types Voluntary: Process blocks Involuntary: End of time quantum or higher priority, runable process gets control of CPU 7

Processes and the kernel processes in private virtual address spaces data data The kernel sets up process execution contexts to virtualize the machine. shared kernel code and data in shared address space system call traps...and upcalls (e.g., signals) Threads or processes enter the kernel for services. CPU and devices force entry to the kernel to handle exceptional events. 8

Virtual address space (VAS) 0 2 n-1 text data BSS user stack args/env kernel text and kernel data 0x0 A typical process VAS space includes: user regions in the lower half Virtual to physical address mappings specific to each process accessible to user or kernel code kernel regions in upper half shared by all processes accessible only to kernel code 2 n -1 0xffffffff 9

Modes of processor execution User mode: Some parts of virtual address space can not be accessed Some instructions (e.g., memory management) can not be executed Kernel mode: Can access kernel address space Is a fixed part of the virtual address space of every process System call puts user into kernel mode 10

Entering the kernel The machine defines a small set of exceptional event types what conditions raise each event The kernel installs handlers for each event at boot time e.g., a table in kernel memory read by the machine The machine transitions to kernel mode only on an exceptional event The kernel defines the event handlers Therefore the kernel chooses what code will execute in kernel mode, and when 11

CPU Events An unnatural change in control flow An interrupt is caused by an external event device requests attention, timer expires, etc. An exception is caused by an executing instruction CPU requires software intervention to handle a fault or trap the kernel defines a handler routine for each event type Q3 12

CPU Process Switch 13

State of a processor At any time, the state of a processor is defined by: Mode: given by the mode bit Is the CPU executing in the protected kernel or a user program? Space: defined by virtual to physical address translations currently in effect What address space is the CPU running in? Once the system is booted, it always runs in some virtual address space. Context: given by register state and execution stream Is the CPU executing a thread/process, or an interrupt handler? Where is the stack? 14

Mode, Space and Context User code executes in a process/thread context in a process address space, in user mode. Can address only user code/data defined for the process, with no access to privileged instructions. System services execute in a process/thread context in a process address space, in kernel mode. Can address kernel memory or user process code/data, with access to protected operations: may sleep in the kernel. 15

Mode, Space and Context Interrupts execute in a system interrupt context in the address space of the interrupted process, in kernel mode. Can access kernel memory and use protected operations. no sleeping! 16

Mode, Space and Context Process Context Application (user space) System calls Exceptions (user + system space) Kernel Context X not allowed Interrupts, System tasks (user space) System call Interrupt occurs User Mode Kernel Mode More privileges 17

Execution of the OS 18

Execution within user processes 19

The UNIX Kernel loaded at boot time and initializes system, creates initial system processes remains in memory and manages the system Resource manager/mediator process is key abstraction Time share (time slice) the CPU, coordinate access to peripherals, manage virtual memory Performs privileged operations 20

The UNIX Kernel Provides synchronization primitives. Well defined entry points syscall, Exceptions, or interrupts. 21

Entry into the Kernel Synchronous kernel performs work on behalf of the process: System call interface (UNIX API): central component of the UNIX API Hardware exceptions: unusual action of process Asynchronous kernel performs tasks that are possibly unrelated to current process. Hardware interrupts: devices assert hardware interrupt mechanism to notify kernel of events which require attention (I/O completion, status change, real time clock etc) System processes scheduled by OS swapper and page daemon. 22

Trap or Interrupt Processing Hardware switches to kernel mode, using the per/process kernel stack HW saves PC, Status word and possibly other state on kernel stack Assembly routine saves any other information necessary and dispatches event On completion a return from interrupt (RFI) instruction is performed 23

Interrupt handling Asynchronous event Name three? Must be serviced in system context, What does this mean? Must not block, Why? What happens to the currently running process? 24

Exception handling Synchronous to the currently running process What is an example? Must run in the current processes context Why? An Interrupt may occur during the processing of an exception or trap Could this be a problem? 25

Software Interrupts Interrupts typically have the highest priority in a system Software interrupts are assigned priorities above that of user processes but below that of interrupts Software interrupts are typically implemented in software Examples: Callout queue processing Network packet processing 26

System Call Interface System call API Why do we need one? Implemented as a set of assembly language stubs Trap into kernel dispatch routine which invokes a high level system call User privileges are verified and any data is copied into kernel (copyin()) On return, copy out any user data (copyout()), check for an Asynchronous System Trap (signal, preemption, etc) 27

Mode switch Revisited How to set and reset the mode? Hardware level support required For example, when an interrupt is detected and the decision to service it is made, at the hardware level the mode bit (part of the Program Status Word) is set appropriately When the ISR is complete it resets the bit 28

Process switching Revisited When can a process switch occur? Anytime the kernel executes for a process Examples: Interrupt: external to the currently running process clock INT, I/O interrupt, memory fault (page or segment) Trap: error exception internal to the program may have a recovery procedure or simply notify and quit Supervisor call: explicit request from the program (system call) Q4 29

Timer interrupt 30

Mode switch vs Process switch When a mode switch occurs, the PCB of the process that was running is still marked Running and is not placed in the Blocked or Ready queue However, depending on what caused the mode switch, a process switch could follow 31