Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Similar documents
Processes The Process Model. Chapter 2. Processes and Threads. Process Termination. Process Creation

Chapter 2 Processes and Threads

Threads. Threads The Thread Model (1) CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

CS450/550 Operating Systems

CS450/550 Operating Systems

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

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

What are they? How do we represent them? Scheduling Something smaller than a process? Threads Synchronizing and Communicating Classic IPC problems

Midterm Exam. October 20th, Thursday NSC

PROCESS SYNCHRONIZATION

Major Requirements of an OS

Processes and Threads

Unit I. Chapter 2: Process and Threads

Learning Outcomes. Processes and Threads. Major Requirements of an Operating System. Processes and Threads

Main Points of the Computer Organization and System Software Module

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

Modern Computers often do lots of things at the same time (web servers, accessing disks, background processes waiting for s,...).

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

Synchronization. CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10)

System Call. Preview. System Call. System Call. System Call 9/7/2018

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

CHAPTER NO - 1 : Introduction:


CS370 Operating Systems Midterm Review

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL. Chap. 2.2 Interprocess Communication

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

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

C09: Process Synchronization

Department of Computer applications. [Part I: Medium Answer Type Questions]

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works?

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

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

Process Description and Control

CSE 153 Design of Operating Systems

CS 370 Operating Systems

Chapter 2 - Processes and Threads

MARUTHI SCHOOL OF BANKING (MSB)

Concurrency and Synchronisation

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01

CSI3131 Final Exam Review

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

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

Processes and Threads

CSC 4320 Test 1 Spring 2017

Process Description and Control

SMD149 - Operating Systems

Jan 20, 2005 Lecture 2: Multiprogramming OS

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

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

Chendu College of Engineering & Technology

Learning Outcomes. Concurrency and Synchronisation. Textbook. Concurrency Example. Inter- Thread and Process Communication. Sections & 2.

Process Management And Synchronization

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

CS153: Midterm (Fall 16)

o Reality The CPU switches between each process rapidly (multiprogramming) Only one program is active at a given time

Concurrency and Synchronisation

Course Syllabus. Operating Systems, Spring 2016, Meni Adler, Danny Hendler & Amnon Meisels

Preview. The Thread Model Motivation of Threads Benefits of Threads Implementation of Thread

148 PROCESSES CHAP. 2

CHAPTER 2: PROCESS MANAGEMENT

8: Scheduling. Scheduling. Mark Handley

Overview. Thread Packages. Threads The Thread Model (1) The Thread Model (2) The Thread Model (3) Thread Usage (1)

Advanced Operating Systems (CS 202) Scheduling (1)

CSC 539: Operating Systems Structure and Design. Spring 2006

Processes and Threads. Processes: Review

Motivation of Threads. Preview. Motivation of Threads. Motivation of Threads. Motivation of Threads. Motivation of Threads 9/12/2018.

Processes. CS3026 Operating Systems Lecture 05

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

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

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

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

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

Concurrency: Deadlock and Starvation. Chapter 6

Lecture 9: Midterm Review

Lecture 2 Process Management

CS370 Operating Systems

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

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

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Processes. Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad COMPUTER SCIENCE AND ENGINEERING QUESTION BANK OPERATING SYSTEMS

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

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

TDIU25: Operating Systems II. Processes, Threads and Scheduling

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Uniprocessor Scheduling

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

Process. A Program In Execution. Program is a set of instructions.

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

Q1. State True/false with jusification if the answer is false:

CSE325 Principles of Operating Systems. Processes. David P. Duggan February 1, 2011

Processes and Threads Implementation

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

Transcription:

Chapter 2 Processes and Threads Processes The Process Model 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Multiprogramming of four programs Conceptual model of 4 independent, sequential processes Only one program active at any instant 1 2 Ways processes can be created Principal events that cause process creation 1. System initialization Unix: init process created by system 2. System calls create child processes 3. User request to create a new process 4. Initiation of a batch job Process Termination Conditions which terminate processes 1. Normal exit (voluntary) 2. Error exit (voluntary) 3. Fatal error (involuntary) 4. Killed by another process (involuntary) 3 4 Process Hierarchies Process States (1) Parent creates a child process, child processes can create its own process Forms a hierarchy UNIX calls this a "process group" Windows has no concept of process hierarchy all processes are created equal 5 Possible process states running blocked ready Transitions between states shown 6

Process States (2) Implementation of Processes (1) Lowest layer of process-structured OS handles interrupts, scheduling Above that layer are sequential processes 7 Fields of a process table entry 8 Implementation of Processes (2) Chapter 2 Processes and Threads Skeleton of what lowest level of OS does when an interrupt occurs 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling 9 10 Inter-process isolation Keeps processes from snooping on each other disrupting each others data core wars But this isolation prevents processes from communicating using memory. operating system aware of communication adds overhead ability to share memory would allow random access to other process state 11 A typical multi-threaded application A word processor with three threads 12

Threads The Thread Model (1) The Thread Model (2) (a) Three processes each with one thread (b) One process with three threads 13 Items shared by all threads in a process Items private to each thread 14 The Thread Model (3) Threads in action Each thread has its own stack A multithreaded Web server 15 16 Threads in action (2) How to support multiple outstanding requests Rough outline of code for previous slide (a) Dispatcher thread (b) Worker thread Three ways to construct a server 17 18

Implementing Threads in User Space Implementing Threads in the Kernel A user-level threads package A threads package managed by the kernel 19 20 Hybrid Implementations Scheduler Activations Goal mimic functionality of kernel threads gain performance of user space threads Avoids unnecessary user/kernel transitions Kernel assigns virtual processors to each process lets runtime system allocate threads to processors Problem: Fundamental reliance on kernel (lower layer) calling procedures in user space (higher layer) Multiplexing user-level threads onto kernel- level threads 21 22 Pop-Up Threads Making Single-Threaded Code Multithreaded (1) Creation of a new thread when message arrives (a) before message arrives (b) after message arrives 23 Conflicts between threads over the use of a global variable 24

Making Single-Threaded Code Multithreaded (2) Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Threads can have private global variables 25 26 Interprocess Communication Race Conditions Critical Regions (1) Four conditions to provide mutual exclusion 1. No two processes simultaneously in critical region 2. No assumptions made about speeds or numbers of CPUs 3. No process running outside its critical region may block another process 4. No process must wait forever to enter its critical region Two processes want to access shared memory at same time 27 28 Critical Regions (2) Mutex: strict alternation Mutual exclusion using critical regions (a) Process 0. (b) Process 1. 29 30

Peterson s Mutex Mutex using test&set 31 Entering and leaving a critical region using the TSL instruction 32 Producer-Consumer w/ race Counting Semaphores & Producer-Consumer 33 34 Mutexes Monitors (1) Implementation of mutex_lock and mutex_unlock 35 Example of a monitor 36

Monitors (2) Monitors (3) Outline of producer-consumer problem with monitors only one monitor procedure active at one time Solution to producer-consumer problem in Java (part 1) buffer has N slots 37 38 Monitors (4) Using messaging to communicate buffer space Solution to producer-consumer problem in Java (part 2) 39 40 Barriers Chapter 2 Processes and Threads Use of a barrier processes approaching a barrier all processes but one blocked at barrier 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling last process arrives, all are let through 41 42

Dining Philosophers (1) Dining Philosophers (2) Philosophers eat/think Eating needs 2 forks Pick one fork at a time How to prevent deadlock A nonsolution to the dining philosophers problem 43 44 Dining Philosophers (3) Dining Philosophers (4) Solution to dining philosophers problem (part 1) 45 46 Solution to dining philosophers problem (part 2) A Solution to the Readers and Writers Problem full code from previous slide 47 48

The Sleeping Barber Problem (1) The Sleeping Barber Problem 49 Solution to sleeping barber problem. 50 Chapter 2 Processes and Threads Scheduling Introduction to Scheduling (1) 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Bursts of CPU usage alternate with periods of I/O wait a CPU-bound process an I/O bound process 51 52 Scheduling: potential goals Scheduling in Batch Systems (1) An example of shortest job first scheduling 53 54

Scheduling in Batch Systems (2) Scheduling in Interactive Systems (1) Three level scheduling 55 Round Robin Scheduling list of runnable processes list of runnable processes after B uses up its quantum 56 Scheduling in Interactive Systems (2) Scheduling in Real-Time Systems Schedulable real-time system Given m periodic events event i occurs within period P i and requires C i seconds Then the load can only be handled if A scheduling algorithm with four priority classes 57 m i= 1 Ci P i 1 58 Policy versus Mechanism Thread Scheduling (1) Separate what is allowed to be done with how it is done a process knows which of its children threads are important and need priority Scheduling algorithm parameterized mechanism in the kernel Parameters filled in by user processes policy set by user process 59 Possible scheduling of user-level threads 50-msec process quantum threads run 5 msec/cpu burst 60

Thread Scheduling (2) Possible scheduling of kernel-level threads 50-msec process quantum threads run 5 msec/cpu burst 61