220 likes | 540 Views
Chapter 4: Processes. Process Concept Process Scheduling Types of shedulars Process states 2-state model 5-state model 6-state model 7-state model Operations on Processes. Process Concept. An operating system executes a variety of programs: Batch system – jobs
E N D
Chapter 4: Processes • Process Concept • Process Scheduling • Types of shedulars • Process states • 2-state model • 5-state model • 6-state model • 7-state model • Operations on Processes Operating System Concepts
Process Concept • 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. • Program: • Resides on disk; passive entity • Peocess • Resides in memory, running on or waiting for cpu; active entiry Operating System Concepts
Process Execution • Execution sequence • Fetch • Decode • Execute • Write results • Set PC to next instruction • Repeat Operating System Concepts
Process Components • A process includes: • CPU state (program counter and other control registers) • code section • data section • Stack (parameters and local variables for sub-functions) • Heap (space for dynamically allocated memory) • Environment (command line parameters) • Process control block (PCB: a kernel data structure) Operating System Concepts
Process control block • A data structure which contains all the information about a running process. • Helps OS to manage processes. • Used in context switching. Operating System Concepts
Basic Types of Process • CPU Bound processes • Which spend more time on cpu and less on I/O e.g. running a mathematical computation like matrix multiplication, running simulations to process given data etc. • I/O Bound processes • Which spend more time on I/O and less on CPU e.g. word processors, data entry software etc. Operating System Concepts
2-State Process Model Dispatch Enter Running Not Running Exit Pause Wait for an I/O Operating System Concepts
Queuing Diagram (2-State Process Model) • Queuing structure for a two state process model is: • Limitations • If all processes in the queue are always ready to execute only then the above queuing discipline will work • But it may also be possible that some processes in the queue are ready to execute, while some are waiting for an I/O operation to complete • So the dispatcher has to scan the list of processes looking for the process that is not blocked and is there in the queue for the longest CMP320 PUCIT Arif Butt
5-State Model • A process may not be in exactly two states when there are more than one processes. For example, when one process has completed its I/O, its can’t get back to CPU because another process may be using it. So this process is ready but can’t run. • Also process may be blocked for more than one reasons like: • A process may be waiting for an event to occur; e.g. a process has created a child process and is waiting for it to return the result • A process may be waiting for a resource which is not available at this time • Process has gone to sleep for some time Operating System Concepts
Process State • As a process executes, it changes state • new: The process is being created. • running: Instructions are being executed. • waiting: The process is waiting for some event to occur e.g. I/O completion or any other signal to come. • ready: The process is waiting to be assigned CPU. • terminated: The process has finished execution. Operating System Concepts
Process Scheduling Queues • Job queue – set of all processes in the system. • Ready queue – set of all processes residing in main memory, ready and waiting to execute. • Device queues – set of processes waiting for an I/O device. • Process migration between the various queues. Operating System Concepts
Queuing Diagram (Using 2-Queues • Limitation: When an event occurs the dispatcher would have to cycle through the entire Blocked Queue to see which process is waiting for that event. • This can cause huge overhead when there may be 100’s or 1000’s of processes CMP320 PUCIT Arif Butt
Ready Queue And Various I/O Device Queues Operating System Concepts
Representation of Process Scheduling Operating System Concepts
6-State Process Model (one suspended state) Limitation: This only allows processes which are blocked to be swapped out. What if there is no blocked process but we still need to free up memory? Solution: Add another state Ready Suspended and swap out a process from the ready state CMP320 PUCIT Arif Butt
7-State Process Model (two suspended state) CMP320 PUCIT Arif Butt