0% found this document useful (0 votes)
28 views

Process Management

The document discusses process management in operating systems. It describes the different states a process can be in, including new, ready, running, blocked, and terminated. It also discusses process creation and termination, interrupts, and context switching. A process control block is used to keep track of process information like state, program counter, CPU registers, and memory allocation. Context switching involves storing the context of the current process and loading the next process to allocate the CPU to a different process.

Uploaded by

Lalamek Rara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Process Management

The document discusses process management in operating systems. It describes the different states a process can be in, including new, ready, running, blocked, and terminated. It also discusses process creation and termination, interrupts, and context switching. A process control block is used to keep track of process information like state, program counter, CPU registers, and memory allocation. Context switching involves storing the context of the current process and loading the next process to allocate the CPU to a different process.

Uploaded by

Lalamek Rara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Process Management

● Process is a fundamental concept in modern operating systems. Process is not a program. A


program may have many processes.
● There are two types of processes,
○ I/O bound processes
○ Processor bound processes
● The process must have at least one through the following requirements.
○ ID
○ Executable code
○ Data needed for execution
○ Execution context (PC, priorities, waiting for I/O or not)
Process Creation
● There can be a reason for process creation.
○ New batch job
○ User starts a program
○ OS creates process to provide a service
○ Running program starts another process
Process Termination
● On process termination, OS reclaims all resources assigned to the process.
● Reasons for process termination:
○ Normal termination,
○ Execution time-limit exceeded,
○ A resource requested is unavailable,
○ An execution error
○ A memory access violation,
○ An operating system or parent process request
○ Parent process has terminated.
Interrupts
● Interrupt is an event that alters the sequence of execution of a process.
● Interrupt can occur due to a time expiry an OS service request I/O completion.
● For example when a disk driver has finished transferring the requested data, it generates an
interrupt to inform the OS that the task is over. Interrupts occur asynchronously to the ongoing
activity of the processor. Thus the times at which interrupts occur are unpredictable.
Interrupt Handling
Generally I/O models are slower than CPU. After each I/O call, CPU has to sit idle until the I/O device
completes the operation, and so the processor saves the status of the current process and executes some
other process. When I/O operation is over, I/O devices issue an interrupt to the CPU then stores the
original process and reserves execution.

Process Management
In a multiprogramming environment, the OS decides which process gets the processor when and for how
much time. This function is called process scheduling. An Operating System does the following activities
for processor managements:
• Keeps track of processor and status of process. The program responsible for this task is known as traffic
controller.
• Allocates the processor (CPU) to a process.
• De-allocates the processor when a process is no longer required.

Process State Diagram( Seven STate Process DIagram)

1. New State

When a process is first created, it occupied the created or new state.In this state, the process waits
admission to the ready state.This admission is approved or delayed is done by the software called Long
Term Scheduler.The operating system’s role is to manage the execution of existing and newly created
processes by moving them between the two states (Ready state, Swapped Out and Ready state) until they
finish.

2. Ready/ Suspend

If a process is in ready state, for a longer time that process moves to the virtual memory in order
to provide space for other high priority resources.The state of this process needs to be resumed,
when the main memory is ok. Then the state is changed again to ready state.
3. Ready State

The process that was at the new state next go to this state. A process in the ready state has been
loaded into main memory until it is executed by the CPU. This is an idle process which is always
ready to run, and never terminates.

4. Running State

This state is called an active or execution state which is executed in the CPU. When in this state,
if the process exceeds its allocated time period, it may be context switch and back to ready state
or temporarily move to blocked state.

5. Blocked/ Suspend

If the main memory is too loaded or to give the space to high priority processes,the processes
with block state in main memory are moved to virtual memory as swapped out and blocked
state.The state of this process needs to be resumed, when the main memory is ok.Then the state is
changed again to blocked state.

6. Blocked state

This state is called the Sleeping state. When a process comes to this state, it is removed from the
CPU and retained in the main memory.A process has to remain “blocked” until their resources
become available. Once the resources are obtained, the blocked process moves to ready state and
then to running state.

7. Terminated state/ Exit State

A process may be terminated either from the running state by completing its execution or killed.
Normally these processes are removed from the main memory and the processes which were not
removed are called “zombies”

Process Control Block (PCB)

A Process Control Block is a data structure maintained by the Operating System for every
process. The PCB is identified by an integer process ID (PID). A PCB keeps all the information
needed to keep track of a process as listed below.
Process State - The current state of the process i.e., whether it is ready, running, waiting, or
whatever.

Process ID - Unique identification for each of the processes in the operating system.

Program Counter - Program Counter is a pointer to the address of the next instruction to be
executed for this process.

CPU registers - Various CPU registers where processes need to be stored for execution for
running state.

Memory management information - This includes the information of page table, memory
limits, Segment table depending on memory used by the operating system.

I/O status information - This includes a list of I/O devices allocated to the process.

Here is a simplified diagram of a PCB:

Context Switching in Operating System


Context switching is a technique or method used by the operating system to switch a process from
one state to another to execute its function using CPUs in the system. When switching performs
in the system, it stores the old running process's status in the form of registers and assigns the
CPU to a new process to execute its tasks. While a new process is running in the system, the
previous process must wait in a ready queue. The execution of the old process starts at that point
where another process stopped it. It defines the characteristics of a multitasking operating system
in which multiple processes share the same CPU to perform multiple tasks without the need for
additional processors in the system.

Steps for Context Switching

There are several steps involved in context switching of the processes. The following diagram
represents the context switching of two processes, P1 to P2, when an interrupt, I/O needs, or
priority-based processes occur in the ready queue of PCB.

You might also like