Process Description and control G.Anuradha (Referred from william stallings and galvin 8 th edition)

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

Processes Management.
Chapter 3 Process Description and Control
Introduction to Processes
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Chapter 3 Process Description and Control
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.
Chapter 3 Process Description and Control
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
Processes and Resources
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?
Process Description and Control A process is sometimes called a task, it is a program in execution.
Using Two Queues. Using Multiple Queues Suspended Processes Processor is faster than I/O so all processes could be waiting for I/O Processor is faster.
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 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Advanced Operating System
Operating System 3 PROCESS DESCRIPTION AND CONTROL.
Chapter 3 Process Description and Control
Requirements of an Operating System Fundamental Task: Process Management The Operating System must – Interleave the execution of multiple processes – Allocate.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z.
Processes Processes Dr. Sunny Jeong & Mr. M.H Park Operating Systems: Internals and Design Principles William Stallings.
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.
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: Processes.
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.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
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.
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,
Process Description and Control
Structure of Processes
Process & its States Lecture 5.
Process Description and Control
Process Description and Control
Process Description and Control
Operating System 3 PROCESS DESCRIPTION AND CONTROL
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Chapter 3: Processes.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Process Description and Control
Chapter 3: Processes Process Concept Process Scheduling
Presentation transcript:

Process Description and control G.Anuradha (Referred from william stallings and galvin 8 th edition)

Contents Introduction Process states Process description Process control

Introduction OS must interleave the execution of multiple processes to maximize processor utilization Proper allocation of resources and avoidance of deadlocks Interprocess communications

Process states What is it? A two-state Process model Creation and termination of processes Five state model Suspended processes

What is it? An operating system executes a variety of programs: – Batch system – jobs – Time-shared systems – user programs or tasks Textbook uses the terms job and process almost interchangeably Process – a program in execution; process execution must progress in sequential fashion A process includes: – program counter – stack – data section

Trace of the Process The behavior of an individual process is shown by listing the sequence of instructions that are executed This list is called a Trace Dispatcher is a small program which switches the processor from one process to another

Process Execution Consider three processes being executed All are in memory (plus the dispatcher) Lets ignore virtual memory for this.

Trace from the processes point of view: Each process runs to completion

Trace from Processors point of view Timeout I/O Timeout

A Two-State Process Model

Queuing Diagram Etc … processes moved by the dispatcher of the OS to the CPU then back to the queue until the task is competed

Review till now What is a Trace? What is a Dispatcher? What are the two states of a two state process model?

Creation and Termination of Processes Life of a process is bounded by its creation and termination When a new process is added – OS builds data structures – Allocates address space in main memory

Process Creation The OS builds a data structure to manage the process Traditionally, the OS created all processes – But it can be useful to let a running process create another This action is called process spawning – Parent Process is the original, creating, process – Child Process is the new process

Reasons for process creation

Process Termination There must be some way that a process can indicate completion. This indication may be: – A HALT instruction generating an interrupt alert to the OS. – A user action (e.g. log off, quitting an application) – A fault or error – Parent process terminating

Process Termination

Five State Model

Five State Process Model Running: process that is currently being executed Ready: process that is prepared to execute when given the opportunity Blocked: process that is waiting for some event to occur New: process that has not yet been loaded into main memory Exit: process that is released because its halted or its aborted

Process model contd… In New state a process is defined which happens in 2 stages – OS gives a Id – Tables needed are allocated and built While in new state the program remains in secondary storage

Process model contd… Termination moves the process to exit state Exit also occurs in two stages – The tables and other information associated with job are Temporarily preserved by OS – Once the utility programs extracts the needed information the OS no longer maintains any data and the process is deleted from the system.

Events that lead to state transition Null  New: new process is created New  ready : Admit – When OS is prepared to take an additional process Ready  Running: Dispatch When OS has to select a process it selects one from the ready state Running  exit : Release – When process is completed or is aborted Running  Ready: Time-out or when the process is preempted Running  Blocked: EventWait – Waiting for I/O or any other system call which is performed by the OS Blocked  Ready :Event Occurs Ready  Exit: In some systems a parent may terminate a child process at any time(not shown in diagram) Blocked  exit:

Single blocked queue diagram

Multiple blocked queues

Suspended Processes What is it? Need for Swapping Other uses of suspension

Need for Swapping The I/O takes more time than processor execution Even with multiprogramming with lots of I/O operations the execution speed of processor comes down This can be avoided by expanding the main memory. But – Cost of main memory is more – Larger memory results in larger processes not more processes Second solution is Swapping

Swapping Swapping is moving part or all of a process from main memory to disk This happens when none of the processes in main memory are in Ready state In the disk the processes are in a suspend queue – which has existing processes that has been kicked out of main memory After this the OS brings some other process in the suspend queue or some new process With swapping we have an additional state- suspend state

State transition diagram with single suspend state

Need for suspend states When swapping takes place the OS can decide to get the process from the new state or from suspend state. This can include more states Ready: Process in main memory and available for execution Blocked: Process in main memory and awaiting an event Blocked/Suspend: Process in secondary memory and awaiting an event Ready/Suspend: Process in secondary memory but is available for execution

STD with suspend states

STD with suspend states contd… StateWhen it occurs Blocked  Blocked/SuspendWhen no ready process or when the process takes more main memory Blocked/suspend  Ready/suspendWhen the event for which its waiting occurs Ready/suspend  ready1.When no ready process in main memory 2.Process in ready/suspend has higher priority than the process in ready state Ready  ready/suspend1.Free up large block of main memory 2.OS may suspend lower-priority ready process than a higher priority blocked process if it believes that the blocked process will be ready soon

STD with suspend states contd… StatesWhen it occurs New  Ready/suspend and new  readyOS should create a PCB and allocate a address space to the process Blocked/suspend  blocked

Reasons for Swapping

Characteristics of a suspended process Process in not immediately available for execution Process may or may not be waiting on an event. Process is placed in a suspended state by an agent:either itself, a parent process, or the OS Process may not be removed from this state until the agent explicitly orders the removal

Process Description What is it? OS control Structures – Memory tables – I/O tables – File tables – Process tables Process Control Structures – Process Location – Process Attributes – Processor state information – Process Control Block

What is Process Description? OS is an entity that manages the use of system resources by processes What information does the OS need to control processes and manage resources for them? Current status of each process and resource How the OS does it? Maintains tables of each entity it’s managing

General Structure of OS control tables

Memory tables Used to keep track of both main and secondary (virtual memory) Memory tables must include the following information – Allocation of main memory to processes – Allocation of secondary memory to processes – Protection attributes of blocks of main or virtual memory such as which processes may access certain shared memory regions – Information needed to manage virtual memory

I/O Tables These tables are used to manage the I/O devices and channels of computer system If an I/O operation is in progress, the OS needs to know the status of the I/O operation and the location in main memory being used as the source/destination of I/O transfer

File Tables These tables provide information about – Existence of files – Location in secondary memory – Current status

The previous tables should cross reference each other. When the OS is initialized, it must have access to some configuration data that define the basic environment and these data must be created outside the OS with human assistance or some auto configuration software

Process Control Structures For managing and control a process the OS should know – Where the process is located – Attributes of the process that are necessary for its management (Process ID, Process State, Location in Memory)

Process Image

Process Location Location of a process image will depend on the memory management scheme Process image is maintained as a contiguous or continuous block of memory This block is maintained in the disk and OS needs to know the location in the disk For OS to manage the process at least a small portion of its image must be maintained in main memory Modern OS uses memory management schemes like paging or segmentation for bringing only a portion of process image in the main memory These details should also be stored in the process table

Process Control Block Information about a process is stored in a Process control Block(PCB) PCB information is grouped into 3 heads – Process Identification – Process state information – Process Control information

Process Identification Identifier of this process Identifier of the process that created this process (parent Process) User Identifier

Processor State Information

Process Control Information

Structure of Process images in virtual memory

Role of PCB It is the most important data structure in an OS Each PCB contains all of the information about a process that is needed by the OS The blocks are read and/or modified by every module in the OS including – Scheduling – Resource allocation – Interrupt processing – Performance monitoring and analysis

Role of PCB Contd… Direct access to PCB acts as a threat to its protection – A bug in a single routine could damage PCB which could destroy the ability to manage other processes – A design change in PCB could affect a number of modules in the OS Solution is to use a handler routine to protect the PCB

Process Control Modes of execution:- – User mode-less privileged mode – Kernel mode- more privileged mode Reasons for two modes – Protect the OS, and OS tables like PCB from interference by user programs In the kernel mode, the software has complete control of the processor and its instructions, registers, and memory Program Status Word (PSW) indicates the mode of execution

Steps in Process Creation 1.Assign a unique PID to the new process:- entry is made to the primary process table 2.Allocate space for the process:-all elements in the process image like, user address space, user stack are to be set 3.Initialize PCB 1.Process ID portion will contain the IDs 2.Processor State Information portion will be initialized to zero(mostly) 3.Process Control Information is initialized based on standard default values plus attributes requested for this process 4.Set Appropriate linkages 5.Create or expand other data structures

Process Control Block (PCB) Information associated with each process Process state Program counter: Address of the next instruction to be executed CPU registers: State information which must be saved when an interrupt occurs. CPU scheduling information: process priority, pointers to scheduling queues, and other scheduling parameters. Memory-management information: base and limit registers, base table and segment table Accounting information: time limits, account and process numbers etc I/O status information: list of I/O devices allocated to the process a list of open files and so on

Process Control Block (PCB)

CPU Switch From Process to Process

Quiz Across 2.complete control of processor 6.less priviledged mode 7.one process creating another 8.List of Instructions Down 1.process waiting for input output operation 3.Program to switch processor from one process to another process 4.moving part or all process from main memory to disk 5.Program in execution

Quiz answers