Processes. Dr. Yingwu Zhu

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

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

Announcements Processes: Part II. Operating Systems. Autumn CS4023

Processes. Process Concept

Operating System Labs. Yuanbin Wu

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

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

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

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

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

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

Lecture 4: Mechanism of process execution. Mythili Vutukuru IIT Bombay

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

Processes. CS3026 Operating Systems Lecture 05

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

Chap 4, 5: Process. Dongkun Shin, SKKU

TCSS 422: OPERATING SYSTEMS

Operating Systems. Lecture 05

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

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

Chapter 3: Processes. Operating System Concepts 9 th Edit9on

Operating Systems. II. Processes

3.1 Introduction. Computers perform operations concurrently

Processes & Threads. Recap of the Last Class. Layered Structure. Virtual Machines. CS 256/456 Dept. of Computer Science, University of Rochester

Computer Systems II. First Two Major Computer System Evolution Steps

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

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

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

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

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

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Operating System Control Structures

CSCE 313: Intro to Computer Systems

Fall 2015 COMP Operating Systems. Lab #3

Process Control. Philipp Koehn. 23 April 2018

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

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

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

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

Chapter 3: Processes

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

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

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

Killing Zombies, Working, Sleeping, and Spawning Children

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

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

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

3. Process Management in xv6

CS 326: Operating Systems. Process Execution. Lecture 5

SMD149 - Operating Systems

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

Processes. CS439: Principles of Computer Systems January 30, 2019

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

Process Description and Control

Chapter 3: Process Concept

Chapter 3: Process Concept

csci3411: 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

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania Fall 2003

Chapter 3: Process Concept

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

518 Lecture Notes Week 3

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

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

CSC 1600 Unix Processes. Goals of This Lecture

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

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

Process Concepts 8/21/2014. CS341: Operating System. Scheduling: Theoretical Analysis

Process Description and Control

Processes and Non-Preemptive Scheduling. Otto J. Anshus

COSC243 Part 2: Operating Systems

Processes COMPSCI 386

Processes and Threads

Processes, Execution and State. Process Operations: fork. Variations on Process Creation. Windows Process Creation.

Operating System Design

CSC 539: Operating Systems Structure and Design. Spring 2006

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

PROCESS CONTROL: PROCESS CREATION: UNIT-VI PROCESS CONTROL III-II R

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

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

The Big Picture So Far. Today: Process Management

Processes and Threads

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

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

Chapter 3: Processes

Lecture 4: Process Management

W4118 Operating Systems. Junfeng Yang

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

Process. Discussion session 3 1/30/2016

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

Threads Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Background: Operating Systems

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20

Transcription:

Processes Dr. Yingwu Zhu

Process

Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++

Entering the kernel (mode) Hardware interrupts Contexts Asynchronous events (I/O, clock, etc.) Do not relate to the context of the current process Software traps Are related to the context of the current procesds E.g., illegal memory access, divide by zero, illegal instruction Software initiated traps System call from the current process The current executing process s address space is active on a trap Saving state Kernel stack switched in upon entering kernel mode Kernel must save machine state before servicing event Registers, flags (program status word), program counter,

System Calls Entry: trap to system call handler Save state Verify parameters are in a valid address Call the function that implements the system call If the function has to (cannot be satisfied immediately), then Context switch to let another ready process to run Put our process in a blocked list

System Calls (cont) Return from system call or interrupt Check for signals to the process Check if another process should run Context switch to let the other process run Put our process on a ready list Calculate time spent in the call for profiling/accounting Restore user process state Return from interrupt

Processes in a Multitasking Environment Multiple concurrent processes Each has a unique identifier: PID Asynchronous events (interrupts) may occur Processes many request operations that take a long time Goals: have some process running at all times Context saving/switching Processes may be suspended and resumed Need to save all state about a process so we can restore it

Process States

Keeping track of processes Process list stores a Process Control Block (PCB) per process PCB contains PID Machine state (registers, PC, stack pointer) Parent & list of children Process state (ready, running, blocked) Memory map Open file descriptors Owner (User ID): determine access & signaling privileges Event descriptor if the process is blocked Signals that have not yet been handled Policy items: scheduling parameters, memory limits Timers for accounting (time & resource utilization) (Process group)

PCB and Hardware State When a process is running, its hardware state (PC, SP, regs, etc.) is in the CPU The hardware registers contain the current values When the OS stops running a process, it saves the current values of the registers into the process PCB When the OS is ready to start executing a new process, it loads the hardware registers from the values stored in that process PCB The process of changing the CPU hardware state from one process to another is called a context switch

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 Depends on Memory speed, #-of-registers to copy, special instructions (single instruction to load/save all registers) A few milliseconds. This can happen 100 or 1000 times a second!

Processes in Linux

Processes in Linux

Processes on Ready & Blocked Queues

Process States: a bit more detail

Creating a process under POSIX fork system call Clones a process into two processes New context is created: duplicate of parent process fork returns 0 to the child process & the process ID to the parent

What happens? Check for available resources Allocate a new PCB Assign a unique PID Check process limits for user Set child state to created Copy data from parent PCB slot to child Increment counts on current directory & open files Copy parent context in memory (or set copy-on-write) Set child state to ready to run Wait for the scheduler to run the process

Fork Example

Running Other Programs execve: replace the current process image with a new one (execl, execle, execlp, execvp ) New process inherits Process group ID Open files Access groups Working directory Root directory Resource usages & limits Timers File mode mask Signal mask

Exec Example

Exit a process

What happens for exit? Ignore all signals Close all open files Release current directory Release current changed root, if any Free memory associated with the process Write an accounting record (if accounting) Make the process state zombie Assign the parent PID of any children to be 1 (init) Send a death of child signal to parent process (SIGCHLD) Context switch

Wait for child process to die

Parent & Child Process

What Kernel does for a process sleeping on a wait?

Signals Inform processes of asynchronous events Processes may specify signal handlers Processes can poke each other (if owned by the same user) Sending a signal kill(int pid, int signal_number) Detecting a signal signal(signal_number, function)

Signal Example

Detecting signals

How does kernel check for signals? Signals may occur asynchronously and often occur when the process is not running The kernel sets a bit in the PCB for that process upon a signal sent to it When the process is brought from ready to running, the kernel does

How does kernel check for signals? When the process is brought from ready to running, the kernel does

Acknowledgement Some slides are adapted from Dr. Paul Krzyzanowski