Process Concept. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Similar documents
Process Concept. Chapter 4: Processes. Diagram of Process State. Process State. Process Control Block (PCB) Process Control Block (PCB)

Chapter 4: Processes

Chapter 4: Processes. Process Concept

Diagram of Process State Process Control Block (PCB)

Processes. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & Apps 1

Chapter 3: Processes. Chapter 3: Processes. Process in Memory. Process Concept. Process State. Diagram of Process State

Part Two - Process Management. Chapter 3: Processes

The Big Picture So Far. Chapter 4: Processes

The Big Picture So Far. Chapter 4: Processes

Chapter 3: Processes. Operating System Concepts Essentials 2 nd Edition

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

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

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.)

Chapter 3: Processes

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

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

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

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

Processes. Operating System Concepts with Java. 4.1 Sana a University, Dr aimen

Chapter 3: Processes. Operating System Concepts 8th Edition, modified by Stewart Weiss

Chapter 3: Process Concept

Chapter 3: Process Concept

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

Chapter 4: Processes. Process Concept

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

Chapter 4: Processes

Chapter 3: Process Concept

Chapter 3: Process Concept

Chapter 4: Processes

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

Chapter 3: Processes

Lecture 2 Process Management

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

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

Chapter 4: Processes. Process Concept. Process State

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

Process Concept Process Scheduling Operations On Process Inter-Process Communication Communication in Client-Server Systems

Chapter 3: Processes. Operating System Concepts 9 th Edition

Chapter 3: Processes. Operating System Concepts 9 th Edition

Module 4: Processes. Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication

Module 4: Processes. Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication

Chapter 3: Process Concept

CS370 Operating Systems

CS420: Operating Systems. Interprocess Communication

Operating System Design

CHAPTER 3 - PROCESS CONCEPT

Chapter 3: Processes. Operating System Concepts 8th Edition

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

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

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

CS307 Operating Systems Processes

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. Process Concept

Course: Operating Systems Instructor: M Umair. M Umair

CS370 Operating Systems

Processes. CSE 2431: Introduction to Operating Systems Reading: Chap. 3, [OSC]

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively.

Chapter 3: Processes

Process. Program Vs. process. During execution, the process may be in one of the following states

Processes and Threads

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

UNIT - II PROCESS MANAGEMENT

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

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

Outline. Interprocess Communication. Interprocess Communication. Communication Models: Message Passing and shared Memory.

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

Page 1. Analogy: Problems: Operating Systems Lecture 7. Operating Systems Lecture 7

ICS Principles of Operating Systems

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

Chapter 3: Processes

CS370 Operating Systems Midterm Review

Interprocess Communication

Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

Processes COMPSCI 386

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Concurrent Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Operating System Concepts Ch. 3: Processes

Exercise (could be a quiz) Solution. Concurrent Programming. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - IV Threads

Processes CHAPTER CHAPTER OBJECTIVES. 3.1 Process Concept

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

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

Process Description and Control

2. PROCESS. Operating System Concepts with Java 8th Edition Silberschatz, Galvin and Gagn

Outlook. Process Concept Process Scheduling Operations on Processes. IPC Examples

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

CSI Module 2: Processes

Chap 4, 5: Process. Dongkun Shin, SKKU

3.1 Introduction. Computers perform operations concurrently

CSC 539: Operating Systems Structure and Design. Spring 2006

Process! Process Creation / Termination! Process Transitions in" the Two-State Process Model! A Two-State Process Model!

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

CHAPTER 2: PROCESS MANAGEMENT

Today: Process Management. The Big Picture So Far. What's in a Process? Example Process State in Memory

Introduction to Multicore Programming

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Transcription:

Process Concept Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr

Topics Covered Process Concept Definition, states, PCB Process Scheduling Scheduling queues, schedulers, context switch Operations on Processes Creation, process tree, termination Cooperating Processes Producer/consumer model Interprocess Communication 2 2

Process Concept

Process Concept Process: a program in execution A process includes Program code Current activity Program counter and processor s registers Stack (temporary data) Subroutine parameters, return address, temporary variables Data section Global variables 4 4

Process State As a process executes, it changes state new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur (I/O completion, signal reception). ready: The process is waiting to be assigned to a process. terminated: The process has finished execution. 5 5

Diagram of Process State 6 6

Process Control Block (PCB) PCB includes Information associated with each process Process state Program counter CPU registers CPU scheduling information Priority, pointers to scheduling queues, etc Memory-management information Values of base and limit registers, page tables, segment tables Accounting information CPU and real-time used, time limits, process numbers, etc I/O status information List of allocated I/O devices, list of open files 7 7

Process Control Block (PCB) 8 8

CPU Switch 9 9

u Area and proc Structure (Unix) proc structure (visible at all times) Process state Identification (PID, UID) Location of kernel address map for the u area Scheduling parameters. u area (visible only when the process is running) Extension of proc structure A pointer to the proc structure System call parameters File descriptors for all open files Internal I/O parameters. 10 10

Process Address Space (Unix) 11 11

Process Scheduling

Job queue Process Scheduling Queues Set of all processes in the system Ready queue Set of all processes that are ready and waiting to execute while residing in main memory Linked list A ready queue header contains pointers to the first and last PCBs Device queues Set of processes waiting for an I/O device Process migration between the various queues 13 13

Ready Queue And I/O Device Queues 14 14

Representation of Process Scheduling 15 15

Context Switch When CPU switches to another process The system must save the state of the old process and load the saved state for the new process Context-switch time is overhead The system does no useful work while switching Time dependent on hardware support. Some processors (DECSYSTEM-20) provide multiple sets of registers A context switch simply includes changing the pointer the current register set 16 16

Operations on Processes

Process Creation (1) Parent process creates children processes Forming a tree of processes Resource allocation Child process can obtain its resources from the OS Child process can share resources with its parent Two possibilities of parent process execution Parent continues to execute concurrently Parent waits until child the process terminates 18 18

Address space Process Creation (2) Child process has a copy of the address space of its parent Child process has a program loaded into its address space UNIX fork system call creates new process Returning zero for the new child Returning the non-zero process identifier to the parent exec system call used after a fork to replace the process memory space with a new program 19 19

Process Creation (3) int main() { int chpid; // Child PID int stat; // Used by parent wait pid_t thischpid; struct command_t command; // Create a process to execute the command if((chpid = fork()) == 0) { // This is the child execv(command.name, command.argv); } } thischpid = wait(&stat); exit(0); 20 20

Swapper and Init Processes Process 0 (swapper) The ancestor of all processes Scheduling (controlling the number of active processes) Process 1 (init ) The first user process when the system boots The ancestor of all user processes When a process terminates, it has any active child, they become orphans and are inherited by init Process 2 (pagedaemon) Maintains a pool of free memory 21 21

Process Tree on a UNIX System 22 22

Normal termination Process Termination Executes last statement and asks the operating system to decide it (exit) Process resources are deallocated by operating system Abnormal termination A process can terminate another process (SIGKILL) 23 23

Cooperating Processes

Cooperating Processes Independent process cannot affect or be affected by the execution of another process Cooperating process can affect or be affected by the execution of another process Advantages of process cooperation Information sharing Computation speed-up Modularity Convenience 25 25

Producer-Consumer Problem Paradigm for cooperating processes producer process produces information that is consumed by a consumer process unbounded-buffer places no practical limit on the size of the buffer bounded-buffer assumes that there is a fixed buffer size 26 26

Bounded Buffer Shared buffer #define BUFFER_SIZE 5 typedef struct {... } item; item buffer[buffer_size]; int in = 0; int out = 0; in: points to the next free position out: points to the first full position in == out: empty ((in+1)%buffer_size) == out: full 27 27

Example of Bounded Buffer Producer Consumer item nextproduced; item nextconsumed; while (1) { while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = nextproduced; in = (in + 1) % BUFFER_SIZE; } while (1) { while (in == out) ; /* do nothing */ nextconsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; } Why (in + 1) % BUFFER_SIZE? 28 28

Example of Bounded Buffer Producer Consumer item nextproduced; item nextconsumed; while (1) { while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */ buffer[in] = nextproduced; in = (in + 1) % BUFFER_SIZE; } while (1) { while (in == out) ; /* do nothing */ nextconsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; } The expression may say that the buffer is empty when in == 5 29 29

Interprocess Communication (IPC) Mechanism for processes to communicate and to synchronize their actions IPC is can be performed by shared memory or message passing IPC based on message passing Two types of operations send and receive Communication link logical implementation (e.g., logical properties) physical implementation (e.g., shared memory, hardware bus) 30 30

Direct Communication Processes must name each other explicitly: send (P, message) send a message to process P receive (Q, message) receive a message from process Q Properties of communication link Links are established automatically A link is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi-directional 31 31

Indirect Communication Messages are directed and received from mailboxes Each mailbox has a unique id Processes can communicate only if they share a mailbox Properties of communication link Link established only if processes share a common mailbox A link may be associated with many processes Each pair of processes may share several communication links Link may be unidirectional or bi-directional 32 32

Operations Indirect Communication create a new mailbox send and receive messages through mailbox destroy a mailbox Primitives are defined as: send(a, message) send a message to mailbox A receive(a, message) receive a message from mailbox A 33 33

Synchronization Message passing may be either blocking or nonblocking Blocking is considered synchronous Non-blocking is considered asynchronous send and receive primitives may be either blocking or non-blocking 34 34

Buffering Queue of messages attached to the link; implemented in one of three ways 1. Zero capacity 0 messages Sender must wait for receiver (rendezvous) 2. Bounded capacity finite length of n messages Sender must wait if link full 3. Unbounded capacity infinite length Sender never waits 35 35