Processes CSCI 444/544 Operating Systems Fall 2008.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

CSE 451: Operating Systems Winter 2007 Module 4 Processes Ed Lazowska Allen Center 570.
IT344 – Operating Systems Winter 2011, Dale Rowe.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Process Concept An operating system executes a variety of programs
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Implementing Processes and Process Management Brian Bershad.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Lecture Topics: 11/1 Processes Process Management
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Module 4 Processes
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
Processes in Unix, Linux, and Windows
Operating Systems Lecture 6.
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process & its States Lecture 5.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2011 Processes
Processes Hank Levy 1.
Processes and Process Management
Chapter 3: Processes.
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Autumn 2009 Module 4 Processes
IT 344: Operating Systems Winter 2008 Module 4 Processes
CSE 451: Operating Systems Winter 2007 Module 4 Processes
Processes in Unix and Windows
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Processes Hank Levy 1.
Presentation transcript:

Processes CSCI 444/544 Operating Systems Fall 2008

Agenda Process concept Process states Process Control Block (PCB) Context switch Operations on processes

What is Process A process is a program in execution –the unit of execution –the unit of scheduling –the dynamic (active) execution context Process is often called a job or task Program is static, just a bunch of bytes

Process vs Program No one-to-one mapping between processes and programs can have multiple processes of the same program One process can invoke multiple programs

What is in a Process A process consists of (at least): –an address space –the code for the running program –the data for the running program –an execution stack and stack pointer (SP) traces state of procedure calls made –the program counter (PC), indicating the next instruction –general-purpose processor registers and their values –a set of OS resources open files, network connections, sound channels, …

A Process’s Address Space 0xFFFFFFFF 0x address space PC SP stack (dynamic allocated mem) static data (data segment) heap (dynamic allocated mem) code (text segment)

Process States Each process has an execution state, which indicates what it is currently doing –new: being created –ready: waiting to be assigned to CPU could run, but another process has the CPU –running: executing on the CPU is the process that currently controls the CPU how many processes can be running simultaneously? –waiting: waiting for an event, e.g., I/O cannot make progress until event happens –terminated: finished execution As a process executes, it moves from state to state

Diagram of Process States

Process Control Block (PCB) PCB is a data structure in the kernel containing the information needed to manage a process The PCB is identified by an integer process ID (PID) also called task control block PCB is the "the manifestation of a process in the kernel” OS keeps all of a process’s hardware execution state in the PCB when the process isn’t running

PCB In Linux: –defined in task_struct ( include/linux/sched.h ) –over 95 fields!

Context Switch The act of switching the CPU from one process to another is called a context switch Context switch time is overhead, no useful work is done while switching –timesharing systems may do 100 or 1000 switches/sec. –takes about 5 microseconds on today’s hardware

Two context switches

Context-switch Implementation Basic idea: save current context including registers to PCB in memory –Tricky: must execute code without using registers –Machine-dependent code Requires special hardware support

State Queues The OS maintains a collection of queues that represent the state of all processes in the system –typically one queue for each state e.g., ready, waiting, … –each PCB is queued onto a state queue according to the current state of the process it represents –as a process changes state, its PCB is unlinked from one queue, and linked onto another The PCBs are moved between queues, which are represented as linked lists.

Ready and Waiting (I/O) Queues

PCBs and State Queues PCBs are data structures –dynamically allocated inside OS memory When a process is created: –OS allocates a PCB for it –OS initializes PCB –OS puts PCB on the correct queue As a process computes: –OS moves its PCB from queue to queue When a process is terminated: –PCB may hang around for a while (exit code…) –eventually, OS deallocates its PCB

Process Creation Four major events that cause processes to be created –System initialization –Execution of a process creation system call by a running process –A user request to create a new process –Initiation of a batch job

Process Creation Parent process create children processes, which, in turn create other processes, forming a tree of processes Two ways to create a process –Build a new empty process from scratch –Copy an existing process and change it appropriately

Process Creation Option 1: New process from scratch steps –Load specific code and data into memory; create empty call stack –Create and initialize PCB –Put process on ready queue pros: no wasted work cons: difficult to setup process correctly –process permissions, environment variables

Process Creation Option 2: clone existing process and change Example: Unix fork() and exec() –fork(): clones calling (parent) process –exec(): replace the process’s address space with a new program Pros: flexible, clean, simple Cons: overhead in copy and then overwrite of memory

Unix process creation fork() system call –creates and initializes a new PCB –creates a new address space –initializes new address space with a copy of the entire contents of the address space of the parent –initializes kernel resources of new process with resources of parent (e.g., open files) –places new PCB on the ready queue the fork() system call “returns twice” –once into the parent, and once into the child –returns the child’s PID to the parent –returns 0 to the child fork() = “clone me”

exec() vs. fork() So how do we start a new program, instead of just forking the old program? –the exec() system call! –int exec(char * prog, char * argv[]) exec() –stops the current process –loads program ‘prog’ into the address space –initializes hardware context, args for new program –places PCB onto ready queue –note: does not create a new process!

Tree of Processes on Solaris

Process Termination Process executes last statement and asks the operating system to delete it (exit) –Output data from child to parent (via wait) –Process’ resources are deallocated by operating system Parent may terminate execution of children processes (abort) –Child has exceeded allocated resources –Task assigned to child is no longer required –If parent is exiting Some operating system do not allow child to continue if its parent terminates