0% found this document useful (0 votes)
22 views12 pages

Understanding Computer Processes and States

The document provides an overview of processes in modern computer systems, defining a process as a program in execution with various states such as New, Ready, Run, Wait, Complete, Suspended Ready, and Suspended Block. It discusses the structure of a Process Control Block (PCB) that contains essential information for process management and highlights the concepts of concurrent and parallel processing, as well as Inter Process Communication (IPC) methods like shared memory and message passing. The document emphasizes the importance of processes in multitasking environments and their management by the operating system.

Uploaded by

unik89025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views12 pages

Understanding Computer Processes and States

The document provides an overview of processes in modern computer systems, defining a process as a program in execution with various states such as New, Ready, Run, Wait, Complete, Suspended Ready, and Suspended Block. It discusses the structure of a Process Control Block (PCB) that contains essential information for process management and highlights the concepts of concurrent and parallel processing, as well as Inter Process Communication (IPC) methods like shared memory and message passing. The document emphasizes the importance of processes in multitasking environments and their management by the operating system.

Uploaded by

unik89025
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to processes

Early computer system allowed any one program to be executed at a


once, current days computer system allow multiple programs to be
loaded in memory and to be executed at the same time or step by step.
This executing multiple programs is being resulted as process. A process
is the unit of work in a modern time-sharing system.

What is a Process?
A process is a program in execution. Process is not as same as program
code but a lot more than it. A process is an 'active' entity as opposed to
program which is considered to be a 'passive' entity. Attributes held by
process include hardware state, memory, CPU etc.

When a program is loaded into the memory and it becomes a process, it


can be divided into four sections ─ stack, heap, text and data. The
following image shows a simplified layout of a process inside main
memory.

Process memory is divided into four sections for efficient working:

• The Text section is made up of the compiled program code, read


in from non-volatile storage when the program is launched.
• The Data section is made up of the global and static variables,
allocated and initialized prior to executing the main.
• The Heap is used for the dynamic memory allocation, and is
managed via calls to new, delete, malloc, free, etc.
• The Stack is used for local variables. Space on the stack is
reserved for local variables when they are declared.

States of Process:
A process is in one of the following states:

1. New: Newly Created Process (or) being-created process.A program


which is going to be picked up by the OS into the main memory is called
a new process.
2. Ready: After creation process moves to Ready state, i.e. the process
is ready for execution. Whenever a process is created, it directly enters
in the ready state, in which, it waits for the CPU to be assigned. The OS
picks the new processes from the secondary memory and put all of
them in the main memory.

The processes which are ready for the execution and reside in the
main memory are called ready state processes. There can be many
processes present in the ready state.

3. Run: Currently running process in CPU (only one process at


a time can be under execution in a single processor).One of the
processes from the ready state will be chosen by the OS depending upon
the scheduling algorithm. Hence, if we have only one CPU in our
system, the number of running processes for a particular time will
always be one. If we have n processors in the system then we can have n
processes running simultaneously.

4. Wait (or Block): When a process requests I/O access. When a


process waits for a certain resource to be assigned or for the input from
the user then the OS move this process to the block or wait state and
assigns the CPU to the other processes.

5. Complete (or terminated): The process completed its execution.


When a process finishes its execution, it comes in the termination state.
All the context of the process (Process Control Block) will also be
deleted the process will be terminated by the Operating system.

6. Suspended Ready: When the ready queue becomes full, some


processes are moved to suspended ready state. A process in the ready
state, which is moved to secondary memory from the main memory due
to lack of the resources (mainly primary memory) is called in the
suspend ready state.

If the main memory is full and a higher priority process comes for the
execution then the OS have to make the room for the process in the main
memory by throwing the lower priority process out into the secondary
memory. The suspend ready processes remain in the secondary memory
until the main memory gets available.

7. Suspended Block: When waiting queue becomes [Link] of


removing the process from the ready queue, it's better to remove the
blocked process which is waiting for some resources in the main
memory. Since it is already waiting for some resource to get available
hence it is better if it waits in the secondary memory and makes room
for the higher priority process. These processes complete their execution
once the main memory gets available and their wait is finished.
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. There is a Process Control Block for each process, enclosing all
the information about the process. It is a data structure, which contains
the following:

S.N. Information & Description

1
Process State

The current state of the process i.e., whether it is ready, running,


waiting, or whatever.

2
Process privileges

This is required to allow/disallow access to system resources.

3
Process ID

Unique identification for each of the process in the operating system.

4
Pointer
A pointer to parent process.

5
Program Counter

Program Counter is a pointer to the address of the next instruction to


be executed for this process.

6
CPU registers

Various CPU registers where process need to be stored for execution


for running state.

7
CPU Scheduling Information

Process priority and other scheduling information which is required to


schedule the process.

8
Memory management information

This includes the information of page table, memory limits, Segment


table depending on memory used by the operating system.

9
Accounting information

This includes the amount of CPU used for process execution, time
limits, etc.
10
IO status information

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

The architecture of a PCB is completely dependent on Operating


System and may contain different information in different operating
systems. Here is a simplified diagram of a PCB −

The PCB is maintained for a process throughout its lifetime, and is


deleted once the process terminates.
Concurrent process
Two processes are said to be concurrent if their execution can overlap in
the time [Link] execution of second process starts before the first

completes. Typically, the processor will be executing instructions for

one program while another (or several other) program(s) are waiting for
I/O from external devices or from an end-user.

Parallel processing
Simultaneous use of more than one CPU or processors to execute a
program or multiple computation threads. Parallel Processing
Systems are designed to speed up the execution of programs by dividing
the program into multiple fragments and processing these fragments
simultaneously. Such systems are multiprocessor systems also known as
tightly coupled systems. Parallel systems deal with the simultaneous use
of multiple computer resources that can include a single computer with
multiple processors.

Inter Process Communication (IPC)


A process can be of two types:

• Independent process.
• Co-operating process.
An independent process is not affected by the execution of other
processes while a co-operating process can be affected by other
executing processes. Though one can think that those processes, which
are running independently, will execute very efficiently but in practical,
there are many situations when co-operative nature can be utilized for
increasing computational speed, convenience and modularity. Inter
process communication (IPC) is a mechanism which allows processes to
communicate each other and synchronize their actions. The
communication between these processes can be seen as a method of co-
operation between them. Processes can communicate with each other
using these two ways:

1. Shared Memory
2. Message passing

An operating system can implement both method of communication.


Communication between processes using shared memory requires
processes to share some or memory. One way of communication using
shared memory can be imagined like this: Suppose process1 and
process2 are executing simultaneously and they share some resources or
use some information from other process, process1 generate information
about certain computations or resources being used and keeps it as a
record in shared memory. When process2 need to use the shared
information, it will check in the record stored in shared memory and take
note of the information generated by process1 and act accordingly.
Processes can use shared memory for extracting information as a record
from other process as well as for delivering any specific
informationtoother process.

Message Passing Method

In this method, processes communicate with each other without using


any kind of shared memory. If two processes p1 and p2 want to
communicate with each other, they proceed as follow:

• Establish a communication link (if a link already exists, no need to


establish it again.)
• Start exchanging messages using basic primitives.
We need at least two primitives:
– send(message, destination) or send(message)
– receive(message, host) or receive(message)

Common questions

Powered by AI

The process lifecycle proceeds through states: New, Ready, Run, Wait (Block), Suspended Ready, and Suspended Block. The transition from New to Ready occurs when the process is loaded into main memory. A process moves from Ready to Run when chosen by the scheduling algorithm for execution. It enters the Wait state if it requires I/O access, and returns to Ready after I/O is complete. Suspended states occur when resources are constrained, prompting a move to secondary memory. Completion leads to the Terminated state .

The primary mechanisms for inter-process communication (IPC) are shared memory and message passing. Shared memory involves processes communicating by reading and writing to a common memory space, which is efficient but requires careful synchronization. In contrast, message passing does not use shared memory; instead, processes communicate by exchanging messages through a communication link. This method is typically easier to implement for distributed systems but might incur more overhead compared to shared memory .

In process scheduling, factors such as process priority, CPU scheduling algorithms, and process state determine the selection of a process from the Ready state for execution. Scheduling algorithms consider criteria like priority levels, CPU time required, and resource availability to ensure optimal processor utilization and system performance. The Process Control Block of each process contains scheduling information that aids in this decision-making process .

The Process Control Block (PCB) plays a crucial role in process management by maintaining the necessary information to track and manage processes. It typically contains the process state, process privileges, process ID, pointer to the parent process, program counter, CPU registers, CPU scheduling information, memory management information, accounting information, and I/O status information. These details facilitate scheduling, resource allocation, and overall process management by the operating system .

In practice, the shared memory method of inter-process communication is implemented by allocating a specific memory segment accessible by cooperating processes. Processes use this shared section to write data that other processes can read, facilitating communication. However, challenges include ensuring data consistency through synchronization mechanisms like locks or semaphores, preventing data races, and efficiently managing memory access across processes to avoid performance degradation .

A process is distinguished from a program as it is an 'active' entity, which is a program in execution, whereas a program is a 'passive' entity that consists merely of code. A process is structured in memory into four sections: the text section contains the compiled program code; the data section includes global and static variables; the heap is used for dynamic memory allocation; and the stack is reserved for local variables .

Parallel processing systems enhance computational efficiency by dividing programs into multiple fragments that can be processed simultaneously using more than one CPU or processor. This is different from concurrent processes, where execution can overlap in time without necessarily involving simultaneous operations. Parallel processing, also called tightly coupled systems, aims to speed up execution by leveraging multiple resources, while concurrency focuses on the potential overlap of process execution timelines .

Multiprocessor systems, especially those in tightly coupled configurations, offer strategic advantages like increased computational power and speed due to simultaneous use of multiple processors. This configuration supports more efficient task execution by distributing workload across processors, reducing bottlenecks, and improving throughput. Tightly coupled systems share memory and resources, facilitating quick task switching and process management, resulting in enhanced performance for computing-intensive applications .

The concepts of process independence and cooperation significantly influence multi-process application design. Independent processes are designed to execute without interference, optimizing speed and reliability. However, cooperative processes benefit multi-process applications by enabling shared computation and resource utilization, increasing efficiency and modularity. Designers must decide between independence for straightforward applications or cooperation for complex, resource-sharing applications to achieve desired performance outcomes .

The suspended state is important in process management as it allows the operating system to free up main memory by moving processes to secondary memory when resources are constrained. This state helps optimize system performance by ensuring that higher priority processes can be allocated the necessary resources for execution. Suspended states, like Suspended Ready and Suspended Block, allow the system to manage memory effectively and maintain process priorities under limited resource conditions .

You might also like