Operating Systems Part of E1.9 - Principles of Computers and Software Engineering. Lecture 3: Introduction to process management

Similar documents
Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Operating Systems Lecture #6: Process Management

Operating System: Scheduling

Chapter 2: OS Overview

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

This tutorial will take you through step by step approach while learning Operating System concepts.

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

1. Computer System Structure and Components

Chapter 6, The Operating System Machine Level

Multi-core Programming System Overview

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

ELEC 377. Operating Systems. Week 1 Class 3

Operating System Tutorial

Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CS414 SP 2007 Assignment 1

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6

CS0206 OPERATING SYSTEMS Prerequisite CS0201, CS0203

Operating Systems 4 th Class

Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

First-class User Level Threads

Operating System Components

Undergraduate Course Syllabus

How To Understand The History Of An Operating System

Operating System Structures

Operating Systems Concepts: Chapter 7: Scheduling Strategies

How To Understand And Understand An Operating System In C Programming

Gildart Haase School of Computer Sciences and Engineering

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Chapter 1 Computer System Overview

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 5 - DBMS Architecture

Linux Process Scheduling Policy

Chapter 2: Processes, Threads, and Agents

Chapter 5 Process Scheduling

CPU Scheduling Outline

CSC 2405: Computer Systems II

Chapter 11 I/O Management and Disk Scheduling

Principles of Operating Systems CS 446/646

Lecture 1 Operating System Overview

Processor Scheduling. Queues Recall OS maintains various queues

CS161: Operating Systems

Embedded Systems. 6. Real-Time Operating Systems

How To Understand How A Process Works In Unix (Shell) (Shell Shell) (Program) (Unix) (For A Non-Program) And (Shell).Orgode) (Powerpoint) (Permanent) (Processes

Operating System Components and Services

Chapter 3 Operating-System Structures

Lecture 25 Symbian OS

Shared Address Space Computing: Programming

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Introduction. What is an Operating System?

W4118 Operating Systems. Instructor: Junfeng Yang

Introduction. Scheduling. Types of scheduling. The basics

CS420: Operating Systems OS Services & System Calls

Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM

Operating Systems. III. Scheduling.

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Virtualization for Cloud Computing

SYSTEM ecos Embedded Configurable Operating System

OPERATING SYSTEM SERVICES

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

Operating Systems, 6 th ed. Test Bank Chapter 7

Performance Evaluation and Optimization of A Custom Native Linux Threads Library

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

OPERATING SYSTEMS STRUCTURES

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

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

Weighted Total Mark. Weighted Exam Mark

Resource Containers: A new facility for resource management in server systems

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Chapter 2: Computer-System Structures. Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General System Architecture

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Why Threads Are A Bad Idea (for most purposes)

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Operating Systems PART -A

CHAPTER 1 INTRODUCTION

Computer Science 4302 Operating Systems. Student Learning Outcomes

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

System Structures. Services Interface Structure

Chapter 11 I/O Management and Disk Scheduling

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Multiprogramming. IT 3123 Hardware and Software Concepts. Program Dispatching. Multiprogramming. Program Dispatching. Program Dispatching

ICS Principles of Operating Systems

CHAPTER 15: Operating Systems: An Overview

Computer-System Architecture

Chapter 2 System Structures

Performance Comparison of RTOS

Chapter 1: Introduction. Chapter 1: Introduction. Operating System Concepts, 7th Edition. Objectives

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

OPERATING SYSTEMS Internais and Design Principles

Transcription:

Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Lecture 3: Introduction to process management

Objectives To introduce the concepts of: Process state and process control block Process scheduling Threads To describe the steps involved in: Process creation Process termination Process switching

Process control block (1) Previous lecture defined process as: Program in execution Consisting of Instructions Data Stack and context Process attributes The state of a process is defined by its current activity (e.g. running, waiting) Process is represented using a process control block.

Process Control Block (2) Typical Process Control Block (PCB) includes: Process state e.g. running, waiting Program counter CPU registers CPU-scheduling information e.g process priority Memory management information e.g values of base and limit registers Accounting information e.g process number I/O status information e.g list of I/O devices allocated and list of open files

Process States (1) Two-state model (1) dispatch Process Creation Not-running running Process Termination pause Processes either running or not-running Processes created as not-running After completion, processes are terminated

Process States (1) Two-state model (2) Process management in the two-state model: Selecting a process for running Dispatching of a process Move process from not-running to running state Restore its context Pausing of a process Move process from running to not-running state Save its context

Process States (1) Two-state model (3) Creation Not-running-queue PN PN-1 P2 P1 dispatch Termination Processor pause Process scheduling decisions: Which process to pick next from the not-running queue? When is a process paused?

Process States (2) Five-state model (1) Two state model: some processes in the not-running queue might not actually be ready to execute e.g waiting for I/O Dispatching of such process is a waste of processor time Need to separate not running processes in more categories: New: process was just created but has not yet entered the system Waiting: process is waiting for I/O Ready: process is ready to execute Result: Five state model

Process States (2) Five-state model (2) Five-state model: Process Creation New admitted ready dispatch running exit Process Termination Terminated I/O or event completion pause Waiting I/O or event wait Three queues: ready, new, waiting

Process States (3) Seven-state model (1) Five-state model: All processes (including those waiting for I/O) are loaded in memory Problem if memory is limited We can store (suspend) some of processes in secondary storage Need to add new two categories of process states: Ready-suspend: Process is ready to execute (not waiting for I/O) but is suspended to secondary storage Waiting-suspend: Process is waiting for I/O and has been suspended to secondary storage. Seven-state model takes into account these new states

Process States (3) Seven-state model (2) Process Creation New admitted ready dispatch running exit Process Termination Terminated Load from disk ready-suspend I/O or event completion Load from disk pause Waiting Suspend to disk I/O or event wait Waiting-suspend

Process States (3) Seven-state model (3) Seven state model illustrates the need for three different types of scheduling Long term scheduling: Determine whether process is admitted to system Determine whether process is placed to ready or ready-suspend queue Medium-term scheduling Determine when to move a process to/from the suspended state Short-term or CPU scheduling Determine when to interrupt a process currently running (note: this is different to processes interrupted by other events (e.g. hardware interrupt)). Determine which process from the ready queue to run next.

Process States (4) Scheduling queues and queuing diagrams (1) Scheduling queues Need even more queues apart from new, ready and waiting, now need new, ready, waiting, waiting-suspend, ready-suspend. Also useful to have various I/O device queues to place processes waiting for a specific device (one per device). Process scheduling moves processes between queues Queuing diagrams

Process States (4) Scheduling queues and queuing diagrams (2) Creation I/O1 Ready-queue PN PN-1 P2 P1 Blocked-waiting-for-I/O1 queue B1 B2 Bm-1 Bm dispatch pause Request I/O1 Termination Processor I/O2 Blocked-waiting-for-I/O2 queue C1 C2 Cm-1 Cm Request I/O2 (Example of a (partial) queuing diagram)

Process States (5) Process Tables OS maintains process tables that hold the PCBs. One entry per PCB Pointer entry in PCB points to the next PCB in the queue. Example: The ready queue and various I/O device queues [Silberschatz et al 2001]

Operations on Processes(1) Overview Major process operations used in the diagrams: Process creation Process termination Process switch

Operations on Processes(2) Process creation (1) Process creation Create new PCB Allocate memory for instructions, data, stack Load instructions and data into allocated memory Initialise stack and context Initialise PCB When? System initialisation Execution of a process-creation system call by a running process (e.g. POSIX fork, Win32 CreateProcess) User creates a new process (e.g. through the shell) Initiation of a batch job

Operations on Processes(2) Process creation (2) The creating process is called parent process; new processes are called children of this process Possibilities after creation: In terms of execution Parent continues execution concurrently with the children Parent waits for some or all of children to terminate in order to continue. In terms of address space of the new process: Child process is a duplicate of the parent process Child process has a new program loaded into it

Operations on Processes(3) Process termination Process termination Release resources allocated to process Delete PCB entries When? Completion of task (normal, voluntary exit) Exit due to error, e.g division by zero, I/O error, protection error. Exit due to termination of parent process (cascading termination) Termination by the OS, e.g if a resource is unavailable or its use has exceeded accounting limits.

Operations on Processes(4) Process switch Process or context switch Kernel saves context (e.g registers, pointers, memory management information etc) into the process PCB Loads context of the new process scheduled to run Context switch time is pure overhead can become substantial depending on whether parts of memory must be saved too. Hardware support can reduce this overhead (e.g by providing multiple sets of registers).

Threads(1) Need for Processes encompass two concepts: Code execution Resource grouping Threads: Can be thought at lightweight processes Share code section, data section and OS resources (e.g open files) with other threads within the process Have own program counter, register set and stack. Allow several threads of execution within the same process Avoid context switching overheads But no protection (e.g. memory) between threads

Threads(2) How? (1) User-level threads: Threads library (e.g POSIX pthreads) Each process starts with a single thread present. A thread can create new threads by calling library procedures, e.g thread_create. Parent thread typically specifies the name of a procedure for the new thread to run Parent thread gets identifier for the new thread. Advantages Fast to create and manage Disadvantages Have to write own scheduling algorithm Difficult to handle with blocking system calls

Threads(2) How? (2) Kernel-level threads Kernel performs creation, scheduling and management in kernel space. Disadvantages: Slower to create and manage than user-level threads Advantages Can easily handle threads with blocking system calls In multiprocessor environments, kernel can schedule threads on different processors Recycling threads

Threads(4) Benefits Responsiveness Interactive processes can perform a lengthy operation in a separate thread, while they handle user s input in another thread Example: Multithreaded Web browser Economy Allocating memory and resources for processes is costly Utilization of multiprocessor architectures

Process management What next? Next three lectures will examine issues introduced today First: Process scheduling Second: Process synchronization Third: Deadlocks

Summary Process management Process state models include two-, five- and seven-state models The steps involved in process creation, termination, and switch were presented. Threads are used to allow for multiple executions to take place within the same process. Next lecture: Process scheduling

Recommended Reading Read chapter 4 and section 5.1 of Silberschatz s book Read chapter 2, sections 2.1-2.2.5 of Tanenbaum s book Rest of chapter 2 will be covered in later lectures Read chapter 3, and section 4.1 of Stallings book