Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.

Slides:



Advertisements
Similar presentations
Process Description and Control
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Chapter 3 Process Description and Control
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Introduction to Processes
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Process Description and Control
The Process Model.
Process Description and Control Module 1.0. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Process Description and Control Chapter 3. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
CSCE 351: Operating System Kernels
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
CSSE Operating Systems
1 Lecture 4: Processes Operating System Spring 2007 Chapter 4 of textbook.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
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.
Process Description and Control
Process Description and Control. Process concepts n Definitions – replaces task, job – program in execution – entity that can be assigned to and executed.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Process Description and Control
Operating System 3 PROCESS DESCRIPTION AND CONTROL.
CSNB224 – AAG 2007 Process Description and Control Chapter 3.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Process Description and Control
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Advanced Operating System
Operating System 3 PROCESS DESCRIPTION AND CONTROL.
Chapter 3 Process Description and Control
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z.
Computer Studies (AL) Operating System Process Management - Process.
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
Politecnico di Milano © 2001 William Fornaciari Operating System Processes Lecturer: William Fornaciari Politecnico di Milano
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.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Process Description and control G.Anuradha (Referred from william stallings and galvin 8 th edition)
CSNB224 – AAG 2007 Process Description and Control Chapter 3.
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.
Processes 2 Introduction to Operating Systems: Module 4.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Types of shedulars Process.
Process Control Management Prepared by: Dhason Operating Systems.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Process Description and Control
Lecture 3 Process.
Process Management Process Concept Why only the global variables?
Process Description and Control
Structure of Processes
Process & its States Lecture 5.
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Process Description and Control
Presentation transcript:

Chapter 41 Processes Chapter 4

2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process is the active execution of one (or more) programs.

3 Processes  A given program, or part of program, can be traversed by several processes, simultaneously or sequentially.  Two users could run the same program at the same time two processes  same code  different data could share the same copy of the code  but individual context.

4 OS Support for Processes  OS must interleave the execution of several processes to maximize CPU usage while providing reasonable response time  OS must allocate resources to processes and avoid deadlock and starvation  OS must support inter-process communication and user creation of processes

5 Dispatcher (short-term scheduler)  An OS program that switches the CPU from one process to another  It prevents a single process from monopolizing CPU time  It decides who goes next according to a scheduling algorithm (chap 6)  The CPU executes instructions in the dispatcher while switching from process A to process B

6 Communications Models Message Passing kernel process B process A M M M Shared Memory kernel process B process A shared memory

7 When does a process get created?  Submission of a batch job  User logs on  Created by OS to provide a service to a user (ex: printing a file)  Spawned by an existing process user programs can create one or more processes during execution The new process is called the “child” and the process that spawned it is called the “parent”

8 When does a process get terminated?  Batch job issues Halt instruction  User logs off  Process executes a service request to terminate  Error or fault conditions

9 Reasons for Process Termination  Normal completion  Time limit exceeded  Memory unavailable  Memory bounds violation  Protection error example: write to read-only file  Arithmetic error  Timeout process waited longer than a specified maximum for an event

10 Reasons for Process Termination  I/O failure  Invalid instruction happens when try to execute data  Privileged instruction  Operating system intervention such as when deadlock occurs  Parent request to terminate child  Parent terminates so child processes terminate automatically  Etc.

11 Simple State Model  Suppose we have a list of active processes and a dispatcher that regularly pauses (interrupts) the active process and selects the next process from a list to get a “turn” (this is “round robin” scheduling)  We can view this with a simple two-state process model

12 Simple Two-State Process Model

13 Limitations to Two-State Model  Two states is enough to handle processes that are always ready to execute  In reality, processes are often “blocked” waiting for the completion of some I/O or other operation  The dispatcher can only restart processes that are really “ready” to run again  We need a more realistic process model  For simplicity, assume there is only one processor, so only one process can be running at a time. (With “symmetric multiprocessing”, one process can be running on each CPU)

14 Process States  Let us start with these states: The Running state  The process that is executing on the CPU is in the Running state The Blocked state  A process that is waiting for something (e.g. I/O) to complete is in the Blocked state The Ready state  A process that is ready to be executed, but not currently assigned to a CPU, is in the Ready state

15 Other Useful States  The New state OS has performed the necessary actions to create the process  has created a process identifier  has created tables needed to manage the process but has not yet committed to execute the process (not yet “admitted”)  because resources are limited

16 Other Useful States  The Exit state Termination moves the process to this state It is no longer eligible for execution Tables and other info are temporarily preserved for auxiliary program  Ex: accounting program that accumulates resource usage for billing users  The process (and its tables) are deleted when the data is no longer needed

17 A Five-state Process Model

18 Process Transitions  Ready --> Running The dispatcher selects a new process to run (scheduling problem: Chapter 6).  Running --> Ready the running process has used its maximum “time slice” (most OS’s do this) the running process is preempted by a higher priority process which is in the ready state ..if the OS supports process priorities

19 Process Transitions  Running --> Blocked When a process requests something for which it must wait  a service of the OS that requires a wait  initiates I/O and must wait for the result  an access to a resource not yet available  waiting for a process to provide input (IPC)  Blocked --> Ready When the event for which it was waiting occurs

20 A Five-state Process Model One more case: Ready --> Exit: For example, parent terminates a child process Child removed directly from Ready queue

21 Single Blocked Queue When a particular event occurs, the scheduler must scan the entire blocked queue looking for processes waiting for that particular event

22 A Better Queuing Discipline  One queue for each event  When event n occurs, all processes in queue “n” are moved to the ready queue

23 The Need for Swapping  We have assumed that all processes have space allocated in main memory  Even with virtual memory, too many processes in main memory deteriorates system performance  Sometimes there will be no processes in the Ready state, because they are all blocked  So the OS could suspend one of these blocked processes: swap it out to auxiliary memory (disk).  And the OS can admit, or activate either a new process, or one that was swapped out earlier  So we will add a Suspend state, for those processes swapped out of memory

24 Add Suspend State

25 A Seven-State Process Model But it is better to add two states to keep track of those that are still blocked, and those which are no longer blocked because their event has occurred..

26 Some New state Transitions  Blocked --> Blocked Suspend When all processes are blocked, the OS may remove a blocked process to bring an unblocked process into memory  The “swap out” frees up memory to allow this to happen  Blocked Suspend --> Ready Suspend When the event for which process has been waiting occurs  Ready Suspend --> Ready When there are no ready processes in main memory Normally, this transition is paired with Blocked --> Blocked suspend for another process (a “swap”)

27 More New state Transitions  Ready--> Ready Suspend When there are no blocked processes and must free up memory for performance reasons  New--> Ready Suspend Probably the preferred way to introduce new processes

28 Constituents of a Process  A “process image” can be thought of as: Program code (“text segment”)  may be shared with other processes Stack(s) Data Section  The Operating Systems keeps track of each process using a Process Control Block

29 Process Control Block

30 Some Other Process Control Information (in PCB)  Interprocess Communication may hold flags and signals for IPC  Process Privileges access to certain memory locations...  Memory management pointers to segment/page tables assigned to this process  Resource ownership and utilization resources in use: open files, I/O devices... history of usage (of CPU time, I/O...)

31 Creation of a Process  Assign a unique process identifier (pid)  Allocate space for the process image code, data, stacks  Initialize process control block usually default values (State = New, no I/O devices or files...)  Set up appropriate linkages Add new PCB to linked list used for the scheduling queue (probably the “NEW” queue)

32 Queues as linked lists of PCBs Silberschatz, Galvin, and Gagne  1999

33 Two Types of Context Switch  Simple Mode Switch to process an interrupt without switching processes: user process is suspended but will be resumed immediately: only save what is necessary to resume execution of the same process (e.g. program counter, couple of registers)  Full Process Switch: process is suspended and another process will get the CPU: save entire context into PCB, load new context from other PCB, update process state. A “heavier duty” operation

34 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999

35 Steps for Full Process Switch  Save context of CPU including program counter and other registers  Update the PCB of the running process with its new state and other info  Move PCB to appropriate queue Ready, Blocked, etc.  Select another process for execution  Update PCB of the selected process Running  Restore CPU context from PCB of the selected process