Implementing Processes and Process Management Brian Bershad.

Slides:



Advertisements
Similar presentations
Chapter 3 Process Description and Control
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.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
Processes CSCI 444/544 Operating Systems Fall 2008.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
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.
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
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
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.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
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.
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,
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS. NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 2 Processes Processes Topics Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Process Control Management Prepared by: Dhason Operating Systems.
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.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Lecture 3 Process.
Processes and threads.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Lecture Topics: 11/1 Processes Process Management
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Processes.
Intro to Processes CSSE 332 Operating Systems
IT 344: Operating Systems Module 4 Processes
Process Virtualization. Process Process is a program that has initiated its execution. A program is a passive entity; whereas a process is an active entity.
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
More examples How many processes does this piece of code create?
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.
Lecture Topics: 11/1 General Operating System Concepts Processes
Processes Hank Levy 1.
Processes and Process Management
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
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Processes Hank Levy 1.
Presentation transcript:

Implementing Processes and Process Management Brian Bershad

210/4/2015 Processes are about virtualizing resources l There are only a limited number of CPUs. l You may want to run more than one program at a time. »why? l We need an abstraction that decouples the physical CPU from the computing resource presented to the program. l This abstraction will trade ease of use for performance and control.

310/4/2015 Process l Basic idea is the process: –process is the unit of of execution –the unit of scheduling and resource allocation –the dynamic (active) execution context (as opposed to a program, which is static) l A process is sometimes called a job or a task or a sequential process. l A sequential process is a program in execution; it defines the sequential, instruction at a time, execution of a program.

410/4/2015 Process Management l Process management deals with several issues: –what are the units of execution? –how are those units of execution represented in the os? –how is work scheduled on the CPU? –what are possible execution states, and how does the system move from one to another?

510/4/2015 What’s in a process? l A process consists of at least: –the code for the running program –the data for the running program –an execution stack showing the state of calls made –the Program Counter, indicating the next instruction –a set of general purpose registers with current values –a set of operating system resources (memory, open files, connections to other programs, etc.) l The process contains all the state for a program in execution.

610/4/2015 Process State l There may be several processes running the same program (e.g., an editor), but each is a distinct process with its own representation. l Each process has an execution state that indicates what it’s currently doing, e.g.: –ready : waiting for the CPU –running : executing instructions on the CPU –waiting : waiting for an event, e.g, I/O completion l As a program executes, it moves from state to state.

Process State Changing Processes move from state to state as a result of actions they perform (e.g., system calls), operating system actions (rescheduling), and external actions (interrupts). 6 New Ready Running Waiting Terminated

810/4/2015 Process Data Structures l At any time, there are many processes in the system, each in it’s particular state. l The OS must have data structures representing each process: this data structure is called the PCB: –Process Control Block. l The PCB contains all of the info about a process. l The PCB is where the OS keeps all of a process’ execution state (e.g., PC, registers) when it is not running. l Q: Can a user process directly manipulate its own PCB?

PCB PCB contains lots of information, e.g.: 8 link (next, prev) stuff process state (running, waiting, etc.) process number Program Counter Stack Pointer General Purpose Registers memory management info username of owner list of open files queue pointers for state queues scheduling info (priority, etc.) accounting info, resource usage I/O states: I/O in progress...other stuff... ProcTable

1010/4/2015 PCBs and Hardware State l When a process is running, it’s Program Counter, stack pointer, registers, etc., are loaded on the CPU (i.e., the hardware registers contain the current values). l When the OS stops a running process, it saves the current values of those registers into the PCB for that process. »save state l When the OS is ready to start executing a waiting process, it loads the hardware registers from the values stored in that process’ PCB. »restore state l The process of switching the CPU from one process to another is called a context switch. Timesharing systems may do 100s or 1000s of context switches a second.

1110/4/2015 Context Switch l Two requirements when we switch contexts. »save away the previous context »restore the next context. »eg, swtch_context(P1, P2) might be an OS call deep deep down. –saves current context in P1’s PCB. –restores the processor to the context of P2’s. l How is context switching different from calling a procedure?

1210/4/2015 Creating a Process l One process can create other processes to do work. These are child processes and the creator is the parent. l In some systems, the parent defines (or donates) resources and privileges for its children. l When a child is created, the parent may either wait for it to finish its task, or continue in parallel. l In Unix, subprocesses are created by a call to Fork; the child is identical to the parent, except for a return code from Fork. The child often begins by executing a new (and different) program within itself, via a call to Exec. (Fork and Exec are Unix system calls.) »this can seem like total magic. »but see last week’s lecture for details

1310/4/2015 State Queues l The OS maintains a collection of queues that represent the state of all processes in the system. l There is typically one queue for each state, e.g., ready, waiting for I/O,... l Each PCB is queued onto a state queue according to its current state. l As a process changes state, its PCB is unlinked from one queue and linked onto another.

State Queues There may be many wait queues, one for each type of wait (wait for process message, wait for timer, wait for specific device...) 11 head ptr tail ptr head ptr tail ptr Ready Queue Header Wait Queue Header PCB_A PCB_W PCB_G PCB_X PCB_M

1510/4/2015 Many Types of Queues Running PCB Disk Network TTY Ready

1610/4/2015 PCBs and State Queues l PCBs are data structures, dynamically allocated in OS memory. l When a process is created, a PCB is allocated to it, initialized, and placed on the correct queue. l As the process computes, its PCB moves from queue to queue. l When the process is terminated, its PCB is deallocated. l Exercise: Show the allocation and queuing that occurs during the UNIX fork() system call

1710/4/2015 Cooperating Processes l Processes can be independent or they can be cooperating to accomplish a single job. l Cooperating processes can be used: –to gain speedup by overlapping activities or performing work in parallel –to better structure an application as a set of small cooperating processes –to share information between jobs l Sometimes processes are structured as a pipeline where each produces work for the next stage that consumes it, and so on. l To see how this works, we need to understand threads. »that’s the next lecture