SMD149 - Operating Systems

Similar documents
3.1 Introduction. Computers perform operations concurrently

Lecture 2 Process Management

CHAPTER 2: PROCESS MANAGEMENT

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

Process- Concept &Process Scheduling OPERATING SYSTEMS

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

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

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

Operating Systems. Figure: Process States. 1 P a g e

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

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

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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

CS370 Operating Systems

OPERATING SYSTEMS: Lesson 4: Process Scheduling

Chapter 5: CPU Scheduling

Unit 3 : Process Management

Scheduling of processes

Operating System Concepts Ch. 5: Scheduling

TDIU25: Operating Systems II. Processes, Threads and Scheduling

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

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

Scheduling - Overview

CS370 Operating 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.

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

CS370 Operating Systems

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

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

Processes and Non-Preemptive Scheduling. Otto J. Anshus

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)

Chapter 5: CPU Scheduling

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

Frequently asked questions from the previous class survey

Course Syllabus. Operating Systems

CPU Scheduling: Objectives

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

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

INF1060: Introduction to Operating Systems and Data Communication. Pål Halvorsen. Wednesday, September 29, 2010

CS3733: Operating Systems

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

Class average is Undergraduates are performing better. Working with low-level microcontroller timers

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

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

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

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

Processes and Threads

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

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

COSC243 Part 2: Operating Systems

Processes and Threads

Process Management Rab Nawaz Jadoon

Chapter 4 Multithreaded Programming

8: Scheduling. Scheduling. Mark Handley

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008

Scheduling in the Supermarket

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Ch 4 : CPU scheduling

by Maria Lima Term Paper for Professor Barrymore Warren Mercy College Division of Mathematics and Computer Information Science

CHAPTER 3 - PROCESS CONCEPT

CS370 Operating Systems

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Uniprocessor Scheduling. Aim of Scheduling

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

LECTURE 3:CPU SCHEDULING

Chapter 5: Processes & Process Concept. Objectives. Process Concept Process Scheduling Operations on Processes. Communication in Client-Server Systems

CSC 539: Operating Systems Structure and Design. Spring 2006

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

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

Uniprocessor Scheduling. Chapter 9

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

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

Process Concept Process in Memory Process State new running waiting ready terminated Diagram of Process State

Last Class: Processes

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

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

Process Description and Control. Chapter 3

* What are the different states for a task in an OS?

Scheduling. The Basics

Killing Zombies, Working, Sleeping, and Spawning Children

Processes, PCB, Context Switch

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

Chapter 9. Uniprocessor Scheduling

Chapter 4: Multithreaded Programming

Processes and Threads

Chapter 6: CPU Scheduling

Process Description and Control

Operating Systems. Process scheduling. Thomas Ropars.

UNIT 2 PROCESSES 2.0 INTRODUCTION

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

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSCE 313: Intro to Computer Systems

Chapter 9 Uniprocessor Scheduling

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

Chapter 5 CPU scheduling

Operating Systems. Scheduling

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

Tasks. Task Implementation and management

Transcription:

SMD149 - Operating Systems Roland Parviainen November 3, 2005 1 / 45

Outline Overview 2 / 45

Process (tasks) are necessary for concurrency Instance of a program in execution Next invocation of the program creates a new process An active entity A process have its own address space Text region Data region Stack region Process control block 3 / 45

Process states Describes the life of a process Running Executing on the processor Ready Can be executed Blocked Waiting for an event OS maintains a ready list and a blocked list 4 / 45

Process states 5 / 45

Process states When a programs are run: A process is created Added to the ready list When a process is at the head of the list, and the processor is available State transition from ready to running The process is dispatched Interval timer (after a time interval or quantum) is used to avoid monopilization of the processor Alternative: cooperative multitasking 6 / 45

Process control block At process creation: Assign an process identification number (PID) Create a process control block (PCB) In kernel space Stored in a process table The process control block contains: PID state program counter sheduling priority credentials parent process, child processes pointers to data and instructions in memory, allocated resources execution context: processor registers 7 / 45

Context switching Performed by the OS to stop executing a running process and begin executing a previously ready process Save the execution context of the running process to its PCB Load the ready process s execution context from its PCB Must be transparent to processes A process that gains the CPU is said to be dispatched The context switch itself costs CPU time (overhead) 8 / 45

9 / 45

Process operations Operating system (OS) provides fundamental services to processes including: Creating processes Destroying processes Suspending processes Resuming processes Changing a process s priority Blocking processes Waking up processes Dispatching processes Interprocess communication (IPC) 10 / 45

Process creation A process may spawn a new process Leads to a hierarchical structure The parent process creates the child process Exactly one parent process creates a child When a parent process is destroyed, operating systems typically respond in one of two ways: Destroy all child processes of that parent Allow child processes to proceed independently of their parents 11 / 45

Example Unix process creation fork system call: duplicates the running process Two identical copies Return value differs (PID of child to parent, 0 to child) All processes has a parent, except init 12 / 45

13 / 45

Suspend/resume Suspending processes By other users or processes Will not return to blocked/ready state until resumed Introduces more states Allows a user to temporarily prevent processes from running 14 / 45

15 / 45

Interrupts Interrupts enable software to asynchronously respond to signals from hardware May be initiated by a running process (e.g., to indicate error) May be initiated by some event not necessarily related to the running process (e.g., I/O operation) Low overhead Polling is an alternative (synchronous) approach Processor repeatedly requests the status of each device Increases overhead 16 / 45

After receiving an interrupt: The processor completes execution of the current instruction, then pauses the current process The processor then executes one of the kernel s interrupt- handling functions The interrupt handler (stored in an array of pointers called the interrupt vector) determines how the system should respond After the interrupt handler completes, the interrupted process is restored and executed or the next process is executed 17 / 45

18 / 45

Interprocess Communication IPC - Interprocess communication must communicate with one another Signals, message passing, shared memory, remote procedure calls (RPC), sockets 19 / 45

Signals Software interrupts Notifies a process of events No data Handling: Catch the signal Ignore the signal Mask the signal 20 / 45

Signals Example Unix signals SIGKILL - kill process SIGTERM - terminate SIGSTOP - stop a process SIGCONT - restart a process SIGUSR1, SIGUSR2 - user-defined SIGALRM - timer 21 / 45

Example - Linux process states 22 / 45

Multithreading Why threads? Concurrency inside processes Examples GUIs Web server CPU intensive calculations on multiprocessor systems Software design Responsivness Efficiency Cooperation 23 / 45

Thread LWP - Light Weight Process Similar to a process: scheduled on a processor, executes independent of other processes and threads Usually belong to a process (HWP - heavy weight process) A thread share most of process resources - address space, open files, etc within a process can run concurrently and cooperate Data unique to each thread: process registers, stack, thread specific data (TSD), signal masks Only one thread - regular process 24 / 45

25 / 45

Thread states 26 / 45

Thread operations and processes have some common operations Create Exit (terminate) Suspend Resume Sleep Wake Cancel Join 27 / 45

Threading models How to implement threads User-level threads (Many to one, n:1) Kernel threads (One to one, 1:1) Mixed model (Many to many, m:n) 28 / 45

User level threads 29 / 45

Kernel-level threads 30 / 45

Combined model 31 / 45

Thread implementations POSIX (P) Win32 Java threads 32 / 45

alternatives Asynchronous (non blocking) calls As used in some user-level threading implementations Not as easy as threads 33 / 45

Decides which process runs at given time Different schedulers will have different goals Maximize throughput Minimize latency Prevent indefinite postponement Complete process by given deadline Maximize processor utilization Most schedulers try to achieve: Fairness Predictability Scalability 34 / 45

Sheduling levels 35 / 45

Preemptive vs. nonpreemptive scheduling Preemptive processes Can be removed from their current processor Can lead to improved response times Important for interactive environments Preempted processes remain in memory Non-preemptive processes Run until completion or until they yield control of a processor Unimportant processes can block important ones indefinitely 36 / 45

Priorities Static priorities Priority assigned to a process does not change Easy to implement Low overhead Not responsive to changes in environment Dynamic priorities Responsive to change Promote smooth interactivity Incur more overhead than static priorities Justified by increased responsiveness 37 / 45

criteria Processor-bound processes Use all available processor time I/O-bound Generates an I/O request quickly and relinquishes processor Batch processes Contains work to be performed with no user interaction Interactive processes Requires frequent user input 38 / 45

algorithms Decide when and for how long each process runs Make choices about Preemptibility Priority Running time Run-time-to-completion Fairness 39 / 45

First In First Out (FIFO) 40 / 45

Round Robin (RR) 41 / 45

Round Robin (RR) Selfish round-robin scheduling Increases priority as process ages Two queues: Active and Holding Favors older processes to avoid unreasonable delays Quantum size Very large quantum size run for long periods Degenerates to FIFO Very small quantum size System spends more time context switching than running processes Middle-ground Long enough for interactive processes to issue I/O request Batch processes still get majority of processor time 42 / 45

More algorithms Shortest Process First (SPF) scheduling Lower average turn-around time as compared to FIFO Non-preemptive Highest-Response-Ratio-Next (HRRN) scheduling Improves upon SPF scheduling by preventing indefinite postponement Looks at how long the process has been waiting But still non-preemptive Shortest-Remaining-Time (SRT) scheduling Preemptive version of SPF Shorter arriving processes preempt a running process Can result in very large variance of response times: long processes wait even longer than under SPF Not always optimal: context switching overhead and preemption of processes near completion 43 / 45

Example - Linux scheduling Tasks have a priority (-20 to 19) Task: process or thread Sceduler runs every timer interrupt (1ms on IA-32) Task run until the time-slice (quantum) expires, it blocks, or a higher priority task is ready Quantum: 10-200ms One run queue for each priority level Each queue is scheduled using round-robin The task at the front of the highest priority level is dispatched During one epoch, all ready processes will run at least once Epoch: 10*n seconds, n: number of ready tasks Static and effective priority Effective priority is static + modification Tasks that blocks gets a higher priority All operations are constant time (O(1)) 44 / 45

45 / 45

http://www.sm.luth.se/csee/courses/smd/149/ Home work assignment 1 deadline: 14 Nov. Next: Systems programming, lab 1 46 / 45