Politecnico di Milano © 2001 William Fornaciari Operating System Processes Lecturer: William Fornaciari Politecnico di Milano

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
Informationsteknologi Tuesday, September 18, 2007 Computer Systems/Operating Systems - Class 61 Today’s class Finish review of C Process description and.
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
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.
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
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.
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
Chapter 3 Process Description and Control
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,
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z.
Process Management CT213 - Computing systems Organization.
Process Description and Control
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.
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.
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
Lecture 3 Process.
Processes and threads.
Process Description and Control
Intro to Processes CSSE 332 Operating Systems
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:

Politecnico di Milano © 2001 William Fornaciari Operating System Processes Lecturer: William Fornaciari Politecnico di Milano

Processes© 2001 William Fornaciari- 2 - SUMMARY Process Concept (3 - 6) Process State (7 -21) Process Control Block(22-28) Operation on Processes(29-42)

Processes© 2001 William Fornaciari- 3 - MAJOR REQUIREMENTS OF AN OPERATING SYSTEM Interleave the execution of the number of processes to maximize processor utilization while providing reasonable response time Allocate resources to processes Support interprocess communication and user creation of processes

Processes© 2001 William Fornaciari- 4 - PROCESS CONCEPT Process = fundamental unit of computation Process – a program in execution; process execution must progress in sequential fashion. A process includes: program counter stack data section

Processes© 2001 William Fornaciari- 5 - PROCESS CATEGORIES An operating system executes a variety of processes : BATCH: Process receives all inputs at the beginning of operation, and produces output only at the end. There is no interaction. INTERACTIVE: Process performs work generally in short bursts and interacts with human users at a terminal. REAL-TIME: Process interacts with external devices or systems having timing constraints which must be met for correct operation. These categories are ordered by increasing criticality.

Processes© 2001 William Fornaciari- 6 - DIFFERENCE BETWEEN PROGRAM AND PROCESS Program: a static, algorithmic description, consists of instructions int main() { int i, prod=1; for(i=0; i<100; ++i) prod = prod*i; } Process: dynamic, consists of instruction executions

Processes© 2001 William Fornaciari- 7 - DISPATCHER Dispatcher functions : Program that moves the processor from one process to another Prevents a single process from monopolizing processor time

Processes© 2001 William Fornaciari- 8 - DISPATCHER : An Example (1) a = initial memory address of Process A b = initial memory address of Process B c = initial memory address of Process C o = initial memory address of Dispatcher program Dispatcher Process C Process B Process A a c b o Main MemoryProgram counter

Processes© 2001 William Fornaciari- 9 - DISPATCHER : An Example (2) Track of each process : a + 0 a + 1 a + 2 a + 3 a + 4 a + 5 a + 6 a + 7 a + 8 a + 9 a + 10 a + 11 c + 0 c + 1 c + 2 c + 3 c + 4 c + 5 c + 6 c + 7 c + 8 c + 9 c + 10 c + 11 b + 0 b + 1 b + 2 b + 3 Track of process: A B C Instruction b + 3 of process B calls an I/O request

Processes© 2001 William Fornaciari DISPATCHER : An Example (3) Interleaved track of the processes Timeout : the operating system let the process to continue its execution at the most for 6 instructions cycles 1 a a a a a a Time out 7 o o o o o o b b b b I/O request 17 o o o o o o c c c c c c Time out 29 o o o o o o a a a a a a Time out 41 o o o o o o c c c c c c Time out

Processes© 2001 William Fornaciari st IMPLEMENTATION : TWO STATE PROCESS MODEL (1) Not Running Processor Enter Dispatch Pause Exit State transition diagram Enter Queue of Not Running Processes DispatchExit Pause Queuing diagram

Processes© 2001 William Fornaciari st IMPLEMENTATION : TWO STATE PROCESS MODEL (2) Two states : Running : instructions are being executed Not Running : the process is waiting to be assigned to a processor Greatest problem : Dispatcher cannot just select the process that has been in the queue the longest because it may be blocked

Processes© 2001 William Fornaciari nd IMPLEMENTATION : FIVE STATE PROCESS MODEL (1) NewReadyRunningExit Blocked Admit Event Occurs Dispatch Release Time-out Event Wait

Processes© 2001 William Fornaciari nd IMPLEMENTATION : FIVE STATE PROCESS MODEL (2) As a process executes, it changes state : Running : Instructions are being executed. Ready : The process is waiting to be assigned to a processor. Blocked : The process is waiting for some event to occur. New : The process is being created. Exit : The process has finished execution.

Processes© 2001 William Fornaciari nd IMPLEMENTATION : An Example State of the processes about the execution track of slide ten

Processes© 2001 William Fornaciari nd IMPLEMENTATION : SINGLE BLOCKED QUEUE Admit Ready Queue* Dispatch Time-out Event Wait Release Processor Blocked Queue* Event Occurs * The queues are FIFO (First In first Out )

Processes© 2001 William Fornaciari nd IMPLEMENTATION : MULTIPLE BLOCKED QUEUES This system provides different queues for each event Admit Ready Queue Dispatch Time-out Release Processor Event 1 Wait Event 1 Queue Event 1 Occurs Event 2 Wait Event 2 Queue Event 2 Occurs

Processes© 2001 William Fornaciari rd IMPLEMENTATION : SEVEN STATE PROCESS MODEL (1) New Admit Suspend Dispatch Time out Ready, suspend Ready Blocked Blocked, suspend Event Occurs Activate Event Occurs Activate Suspend RunningExit Event Wait

Processes© 2001 William Fornaciari rd IMPLEMENTATION : SEVEN STATE PROCESS MODEL (2) Processor is faster than I/O so all processes could be waiting for I/O Swap these processes to disk to free up more memory Blocked state becomes suspend state when swapped to disk Two new states : Blocked-suspend : the swapped process is waiting for some event to occur Ready-suspend : the process is on the disk but isn’t waiting for events

Processes© 2001 William Fornaciari PROCESS SUSPENSION : CAUSES Swap : the operating system has to free up more memory to load a process which is ready to be executed. Operating System Cause : the operating system can suspend a background process, an utility process or a process which is causing a problem. Interactive User request : a user want to suspend the execution of a program to debug or to use a resource.

Processes© 2001 William Fornaciari PROCESS SUSPENSION : CAUSES Temporization : a process can be executed periodically and can be suspended while it is waiting the next time interval. Parent Process Request : a parent process can suspend the execution of a child to analyse or to modify a suspended process.

Processes© 2001 William Fornaciari RESOURCE MANAGEMENT The operating system is the entity which manages the use of system resources by the processes P1 is being executed P2 is blocked because it’s waiting the I/O resource used by P1 Pn is loaded on the disk (suspended) P1PnP2 Processor I/O Main Memory I/O Virtual memory Computer Resources

Processes© 2001 William Fornaciari PROCESS IMAGE STRUCTURE IN VIRTUAL MEMORY (1) Processor State Information Process Control Information Process Identification System Stack User Space (programs, datas) Shared Space PCB Processor State Information Process Control Information Process Identification System Stack User Space (programs, datas) Shared Space Processor State Information Process Control Information Process Identification System Stack User Space (programs, datas) Shared Space

Processes© 2001 William Fornaciari PROCESS IMAGE STRUCTURE IN VIRTUAL MEMORY (2) PCB (Process Control Block) : structure of data used by the operating system to control the processes. System stack : each process has one or more than one LIFO stacks. This stack is used to register parameters and addresses of the system procedure calls. User space : the program which has to be executed and the structure of data the program is able to modify. Shared space : space shared by other processes.

Processes© 2001 William Fornaciari PCB (1) Process Identification : Unique numeric identifier may be an index into the primary process table Parent process identifier who created this process User identifier who is responsible for the job

Processes© 2001 William Fornaciari PCB (2) Process state informations : User-visible registers Control and status registers Program status word (PSW) : contains status information Example: the EFLAGS register on Pentium machines Process stack pointers

Processes© 2001 William Fornaciari PCB (3.1) Process Control Information : additional information needed by the operating system to control and coordinate the various active processes scheduling and state information process state, priority, waited event data structuring relationship among processes interprocess communication flags, signals, messages

Processes© 2001 William Fornaciari PCB (3.2) process privileges executable instructions, memory accesses memory management information about virtual memory used by the process resource ownership and utilization resources controlled by the process

Processes© 2001 William Fornaciari FUNCTIONS OF THE KERNEL : PROCESS MANAGEMENT Process creation and termination Process scheduling and dispatching Process switching Process synchronization and support for inter- process communication Management of process control blocks

Processes© 2001 William Fornaciari PROCESS CREATION STEPS 1Assign a unique process identifier and add a new entry in the main process table 2Allocate space for the process and for the process image 3Initialize process control block and set up the stack pointers 4Set up appropriate linkages Ex: add new process to linked list used for scheduling queue 5Other Ex : maintain an accounting file

Processes© 2001 William Fornaciari CAUSES OF PROCESS CREATION Submission of a batch job User logs on Create to provide a service such as printing Spawned by an existing process

Processes© 2001 William Fornaciari PROCESS TERMINATION Batch job issues Halt instruction User logs off Process executes a service request to terminate Error and fault conditions Steps : 1Process executes last statement and asks the operating system to decide it. 2Output data from child to parent. 3Process’ resources are deallocated by operating system.

Processes© 2001 William Fornaciari REASONS FOR PROCESS TERMINATION (1) Normal completion Time limit exceeded Memory unavailable Memory bounds violation Protection error ex : write to read-only file Arithmetic error ex : division by 0

Processes© 2001 William Fornaciari REASONS FOR PROCESS TERMINATION (2) Time overrun process waited longer than a specified maximum for an event I/O failure Invalid instruction ex : try to execute data Privileged instruction Data misuse ex : use of not initialized data

Processes© 2001 William Fornaciari REASONS FOR PROCESS TERMINATION (3) Operating system intervention ex : deadlock occurs Parent terminates so child processes terminate Parent request

Processes© 2001 William Fornaciari CPU SWITCH FROM PROCESS TO PROCESS

Processes© 2001 William Fornaciari WHEN TO SWITCH A PROCESS Interrupts (caused by an external event) Clock :process has executed for the maximum allowable time slice I/O : other process is using this I/O resource Memory fault : memory address is in virtual memory so it must be brought into main memory Trap (caused by an internal event) error occurred : if the error is fatal, the trap may cause process to be moved to Exit state Supervisor call the process calls a kernel procedure

Processes© 2001 William Fornaciari CHANGE OF EXECUTION MODE (Interrupt Cycle) 1Save the context of the program which is being executed 2Set the program counter on the address of the beginning of the interrupt handler program 3Change the user mode for the kernel mode The change of execution mode can happen without changing the process state

Processes© 2001 William Fornaciari CHANGE OF PROCESS STATE 1Save context of processor including program counter and other registers 2Update the process control block with the new state and any accounting information 3Move process control block to appropriate queue - ready, blocked 4Select another process for execution 5Update the process control block of the process selected 6Update memory-management data structures 7Restore context of the selected process

Processes© 2001 William Fornaciari EXECUTION OF THE OPERATING SYSTEM (1) Non Process Kernel (for traditional operating system) execute kernel outside of any process operating system code is executed as a separate entity that operates in privileged mode process concept is used only for the user programs Kernel P1P2Pn

Processes© 2001 William Fornaciari EXECUTION OF THE OPERATING SYSTEM (2) Execution Within User Processes (for operating system of minicomputer) operating system software within context of a user process process executes in privileged mode when executing operating system code process can execute either a user program or an operating system program Process Change Function P1 Operating System Functions P2 Operating System Functions Pn Operating System Functions

Processes© 2001 William Fornaciari EXECUTION OF THE OPERATING SYSTEM (3) Process-Based Operating System (for operating system of multicomputer) major kernel functions are separate processes a process is invoked by the operating system useful if some operating system services are executed by dedicated processors Process Change Function Pn U1UnU2 P2P1

Processes© 2001 William Fornaciari REFERENCES Stallings W. Sistemi Operativi Jackson Libri Silberschatz A. Sistemi Operativi Addison-Wesley Tanenbaum A. I Moderni Sistemi Operativi Jackson Libri Web Material (see web page of the course)