Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

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

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

CSC 539: Operating Systems Structure and Design. Spring 2006

Lecture Topics. Announcements. Today: Threads (Stallings, chapter , 4.6) Next: Concurrency (Stallings, chapter , 5.

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Chap 4, 5: Process. Dongkun Shin, SKKU

CS 475. Process = Address space + one thread of control Concurrent program = multiple threads of control

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

W4118 Operating Systems. Junfeng Yang

OPERATING SYSTEM. Chapter 4: Threads

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

Processes. Dr. Yingwu Zhu

Chapter 4: Processes. Process Concept

Chapter 4: Threads. Chapter 4: Threads

Processes. Process Concept

Chapter 4: Processes

Chapter 4: Threads. Chapter 4: Threads

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

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

Process Description and Control

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

Chapter 4: Multithreaded Programming

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

Agenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

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

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Last class: Today: Thread Background. Thread Systems

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

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

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

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel

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

Fall 2015 COMP Operating Systems. Lab #3

Diagram of Process State Process Control Block (PCB)

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

Chapter 3: Processes. Operating System Concepts 8th Edition

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

What is a Process? Processes and Process Management Details for running a program

csci3411: Operating Systems

Processes and Threads

Killing Zombies, Working, Sleeping, and Spawning Children

Lecture 4: Memory Management & The Programming Interface

CS420: Operating Systems

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

CS510 Operating System Foundations. Jonathan Walpole

Chapter 4: Threads. Operating System Concepts 9 th Edition

CS307: Operating Systems

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

What is a Process. Processes. Programs and Processes. System Classification 3/5/2013. Process: An execution stream and its associated state

CSE 153 Design of Operating Systems Fall 2018

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

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

Chapter 4: Processes

Processes and Threads

EECS 482 Introduction to Operating Systems

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

COMP 3100 Operating Systems

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

3.1 Introduction. Computers perform operations concurrently

Process Description and Control

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Chapter 4: Processes

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

Chapter 4: Processes. Process Concept

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

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

Operating System Design

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

Processes. Johan Montelius KTH

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Chapter 4: Threads. Operating System Concepts 9 th Edition

Processes. CS439: Principles of Computer Systems January 24, 2018

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

A process. the stack

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

Process Time. Steven M. Bellovin January 25,

Lecture 2 Process Management

The Big Picture So Far. Chapter 4: Processes

CS 450 Operating System Week 4 Lecture Notes

Processes. Sanzheng Qiao. December, Department of Computing and Software

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

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

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

Processes & Threads. Recap of the Last Class. Microkernel System Architecture. Layered Structure

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

Chapter 4: Processes. Process Concept. Process State

COSC243 Part 2: Operating Systems

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts

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

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

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

Chapter 3: Process Concept

Chapter 3: Process Concept

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

Transcription:

Processes Design, Spring 2011 Department of Computer Science

Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode instruction Execute instruction CPU Memory 2

Image of Executing Program 100 mov (R1), R2 104 add R1,4,R1 108 Mov (R1), R3 112 add R2,R3,R3 Memory 2000 4 2004 8 R1: 2000 R2: R3: PC: 100 CPU 3

Higher-Level Languages public class foo { } static private int yv = 0; static private int nv = 0; public static void main() { foo foo_obj = new foo; foo_obj->cheat(); } public cheat() { int tyv = yv; yv = yv + 1; if (tyv < 10) { cheat(); } } 4 How to map a program like this to a Von Neuman machine? Where to keep yv, nv? What about foo_obj and tyv? How to do foo_obj->cheat()?

Run Time Storage Organization Code Globals Stack Heap Memory Each variable must be assigned a storage class Global (static) variables Allocated in globals region at compile-time Method local variables and parameters Allocate dynamically on stack Dynamically created objects (using new) Allocate from heap Objects live beyond invocation of a method Garbage collected when no longer live Pointer to next instruction to be executed kept in special register called PC Variables also cached in registers 5

Process Process = system abstraction for the set of resources required for executing a program = a running instance of a program = memory image + registers content (+ I/O state) The stack + registers content represent the execution context or thread of control 6

What About The OS? Recall that one of the function of an OS is to provide a virtual machine interface that makes programming the machine easier So, a process memory image must also contain the OS Memory OS Code Globals Stack Heap Code Globals Stack Heap OS data space is used to store things like file descriptors for files being accessed by the process, status of I/O devices, etc. 7

What Happens When There Are More Than One Running Process? OS P0 Code Globals Stack P1 Heap P2 8

Process Control Block Each process has per-process state maintained by the OS Identification: process, parent process, user, group, etc. Execution contexts: threads Address space: virtual memory I/O state: file handles (file system), communication endpoints (network), etc. Accounting information For each process, this state is maintained in a process control block (PCB) This is just data in the OS data space Think of it as objects of a class 9

Process Control Block 10

Process States 11

Switching Between Processes 12

Ready Queue And Various I/O Device Queues 13

Process Creation How to create a process? System call. In UNIX, a process can create another process using the fork() system call int pid = fork(); /* this is in C */ The creating process is called the parent and the new process is called the child The child process is created as a copy of the parent process (process image and process control structure) except for the identification and scheduling state Parent and child processes run in two different address spaces By default, there s no memory sharing Process creation is expensive because of this copying The exec() call is provided for the newly created process to run a different program than that of the parent 14

Process Creation fork() code PCBs fork() exec() 15

Example of Process Creation Using Fork The UNIX shell is command-line interpreter whose basic purpose is for user to run applications on a UNIX system cmd arg1 arg2... argn 16

Process Death (or Murder) One process can wait for another process to finish using the wait() system call Can wait for a child to finish as shown in the example Can also wait for an arbitrary process if know its PID Can kill another process using the kill() system call What all happens when kill() is invoked? What if the victim process doesn t want to die? 17

A Tree of Processes On A Typical UNIX System 18

Signals User program can invoke OS services by using system calls What if the program wants the OS to notify it asynchronously when some event occurs? Signals UNIX mechanism for OS to notify a user program when an event of interest occurs Potentially interesting events are predefined: e.g., segmentation violation, message arrival, kill, etc. When interested in handling a particular event (signal), a process indicates its interest to the OS and gives the OS a procedure that should be invoked in the upcall How does a process indicate its interest in handling a signal? 19

Signals (Cont d) When an event of interest occurs: The kernel handles the event first, then modifies the process s stack to look as if the process s code made a procedure call to the signal handler. Puts an activation record on the userlevel stack corresponding to the event handler When the user process is scheduled next it executes the handler first From the handler the user process returns to where it was when the event occurred B A Handler B A 20

Process: Summary An instantiation of a program System abstraction: the set of resources required for executing a program Execution context(s) Address space File handles, communication endpoints, etc. Historically, all of the above lumped into a single abstraction More recently, split into several abstractions Threads, address space, protection domain, etc. OS process management: Supports user creation of processes and interprocess communication (IPC) Allocates resources to processes according to specific policies Interleaves the execution of multiple processes to increase system utilization 21