The Wayback Machine - https://web.archive.org/web/20240927083038/https://www.geeksforgeeks.org/introduction-of-process-management/
Open In App

Introduction of Process Management

Last Updated : 12 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

A process is a program in execution. For example, when we write a program in C or C++ and compile it, the compiler creates binary code. The original code and binary code are both programs. When we actually run the binary code, it becomes a process. A process is an ‘active’ entity instead of a program, which is considered a ‘passive’ entity. A single program can create many processes when run multiple times; for example, when we open a .exe or binary file multiple times, multiple instances begin (multiple processes are created). 

In this article, we will discuss process management in detail, along with the different states of a process, its advantages, disadvantages, etc.

What is Process Management?

Process management is a key part of an operating system. It controls how processes are carried out, and controls how your computer runs by handling the active processes. This includes stopping processes, setting which processes should get more attention, and many more. You can manage processes on your own computer too.

The OS is responsible for managing the start, stop, and scheduling of processes, which are programs running on the system. The operating system uses a number of methods to prevent deadlocks, facilitate inter-process communication, and synchronize processes. Efficient resource allocation, conflict-free process execution, and optimal system performance are all guaranteed by competent process management. This essential component of an operating system enables the execution of numerous applications at once, enhancing system utilization and responsiveness.

How Does a Process Look Like in Memory? 

A process in memory is divided into several distinct sections, each serving a different purpose. Here’s how a process typically looks in memory:

Process Management

  • Text Section: A Process, sometimes known as the Text Section, also includes the current activity represented by the value of the Program Counter. 
  • Stack: The stack contains temporary data, such as function parameters, returns addresses, and local variables. 
  • Data Section: Contains the global variable. 
  • Heap Section: Dynamically memory allocated to process during its run time. 

Characteristics of a Process

A process has the following attributes.

  • Process Id: A unique identifier assigned by the operating system.
  • Process State: Can be ready, running, etc.
  • CPU Registers: Like the Program Counter (CPU registers must be saved and restored when a process is swapped in and out of the CPU)
  • Accounts Information: Amount of CPU used for process execution, time limits, execution ID, etc
  • I/O Status Information: For example, devices allocated to the process, open files, etc
  • CPU Scheduling Information: For example, Priority (Different processes may have different priorities, for example, a shorter process assigned high priority in the shortest job first scheduling)

All of the above attributes of a process are also known as the context of the process. Every process has its own process control block(PCB), i.e. each process will have a unique PCB. All of the above attributes are part of the PCB. 

States of Process

A process is in one of the following states: 

  • New: Newly Created Process (or) being-created process.
  • Ready: After the creation process moves to the Ready state, i.e. the process is ready for execution.
  • Running: Currently running process in CPU (only one process at a time can be under execution in a single processor).
  • Wait (or Block): When a process requests I/O access.
  • Complete (or Terminated): The process completed its execution.
  • Suspended Ready: When the ready queue becomes full, some processes are moved to a suspended ready state
  • Suspended Block: When the waiting queue becomes full.

process-states

Process Operations

Process operations in an operating system refer to the various activities the OS performs to manage processes. These operations include process creation, process scheduling, execution and killing the process. Here are the key process operations:

Process Operations

Process Operations

Process Creation

Process creation in an operating system (OS) is the act of generating a new process. This new process is an instance of a program that can execute independently.

Scheduling

Once a process is ready to run, it enters the “ready queue.” The scheduler’s job is to pick a process from this queue and start its execution.

Execution

Execution means the CPU starts working on the process. During this time, the process might:

  • Move to a waiting queue if it needs to perform an I/O operation.
  • Get blocked if a higher-priority process needs the CPU.

Killing the Process

After the process finishes its tasks, the operating system ends it and removes its Process Control Block (PCB).

Context Switching of Process

The process of saving the context of one process and loading the context of another process is known as Context Switching. In simple terms, it is like loading and unloading the process from the running state to the ready state. 

When Does Context Switching Happen? 

Context Switching Happen:

  • When a high-priority process comes to a ready state (i.e. with higher priority than the running process). 
  • An Interrupt occurs.
  • User and kernel-mode switch (It is not necessary though) 
  • Preemptive CPU scheduling is used. 

Context Switch vs Mode Switch

A mode switch occurs when the CPU privilege level is changed, for example when a system call is made or a fault occurs. The kernel works in more a privileged mode than a standard user task. If a user process wants to access things that are only accessible to the kernel, a mode switch must occur. The currently executing process need not be changed during a mode switch. A mode switch typically occurs for a process context switch to occur. Only the kernel can cause a context switch. 

CPU-Bound vs I/O-Bound Processes

A CPU-bound process requires more CPU time or spends more time in the running state. An I/O-bound process requires more I/O time and less CPU time. An I/O-bound process spends more time in the waiting state. 

Process planning is an integral part of the process management operating system. It refers to the mechanism used by the operating system to determine which process to run next. The goal of process scheduling is to improve overall system performance by maximizing CPU utilization, minimizing execution time, and improving system response time. 

Process Scheduling Algorithms

The operating system can use different scheduling algorithms to schedule processes. Here are some  commonly used timing algorithms: 

  • First-Come, First-Served (FCFS): This is the simplest scheduling algorithm, where the process is executed on a first-come, first-served basis. FCFS is non-preemptive, which means that once a process starts executing, it continues until it is finished or waiting for I/O. 
  • Shortest Job First (SJF): SJF is a proactive scheduling algorithm that selects the process with the shortest burst time. The burst time is the time a process takes to complete its execution. SJF minimizes the average waiting time of processes.  
  • Round Robin (RR): Round Robin is a proactive scheduling algorithm that reserves a fixed amount of time in a round for each process. If a process does not complete its execution within the specified time, it is blocked and added to the end of the queue. RR ensures fair distribution of CPU time to all processes and avoids starvation.
  • Priority Scheduling: This scheduling algorithm assigns priority to each process and the process with the highest priority is executed first. Priority can be set based on process type, importance, or resource requirements.  
  • Multilevel Queue: This scheduling algorithm divides the ready queue into several separate queues,  each queue having a different priority. Processes are queued based on their priority, and each queue uses its own scheduling algorithm. This scheduling algorithm is useful in scenarios where different types of processes have different priorities.

Advantages of Process Management

  • Running Multiple Programs: Process management lets you run multiple applications at the same time, for example, listen to music while browsing the web.
  • Process Isolation: It ensures that different programs don’t interfere with each other, so a problem in one program won’t crash another.
  • Fair Resource Use: It makes sure resources like CPU time and memory are shared fairly among programs, so even lower-priority programs get a chance to run.
  • Smooth Switching: It efficiently handles switching between programs, saving and loading their states quickly to keep the system responsive and minimize delays.

Disadvantages of Process Management

  • Overhead: Process management uses system resources because the OS needs to keep track of various data structures and scheduling queues. This requires CPU time and memory, which can affect the system’s performance.
  • Complexity: Designing and maintaining an OS is complicated due to the need for complex scheduling algorithms and resource allocation methods.
  • Deadlocks: To keep processes running smoothly together, the OS uses mechanisms like semaphores and mutex locks. However, these can lead to deadlocks, where processes get stuck waiting for each other indefinitely.
  • Increased Context Switching: In multitasking systems, the OS frequently switches between processes. Storing and loading the state of each process (context switching) takes time and computing power, which can slow down the system.

Conclusion

In conclusion, process management is a important function of an operating system, ensuring that multiple programs can run smoothly and efficiently. It involves creating, scheduling, and terminating processes, as well as managing resources and handling communication between processes. Effective process management optimizes the use of system resources, maintains system stability, and enhances the overall performance and responsiveness of the computer. Understanding and implementing robust process management strategies are crucial for maintaining an efficient and reliable computing environment.

GATE-CS-Questions on Process Management

Q.1: Which of the following need not necessarily be saved on a context switch between processes? (GATE-CS-2000) 

(A) General purpose registers 

(B) Translation lookaside buffer 

(C) Program counter 

(D) All of the above 

Answer: (B)

In a process context switch, the state of the first process must be saved somehow, so that when the scheduler gets back to the execution of the first process, it can restore this state and continue. The state of the process includes all the registers that the process may be using, especially the program counter, plus any other operating system-specific data that may be necessary. A translation look-aside buffer (TLB) is a CPU cache that memory management hardware uses to improve virtual address translation speed. A TLB has a fixed number of slots that contain page table entries, which map virtual addresses to physical addresses. On a context switch, some TLB entries can become invalid, since the virtual-to-physical mapping is different. The simplest strategy to deal with this is to completely flush the TLB. 

Q.2: The time taken to switch between user and kernel modes of execution is t1 while the time taken to switch between two processes is t2. Which of the following is TRUE? (GATE-CS-2011) 

(A) t1 > t2 

(B) t1 = t2 

(C) t1 < t2 

(D) nothing can be said about the relation between t1 and t2. 

Answer: (C)

Process switching involves a mode switch. Context switching can occur only in kernel mode. 

Frequently Asked Questions on Process Management – FAQs

Why process management is important?

Process management is important in an operating system because it ensures that all the programs running on your computer work smoothly and efficiently.

What is the main difference between process manager and memory manager?

Processes in the system are manage by processor manager and also it is responsible for the sharing of the CPU. whereas, memory in the system is managed by memory manager and it is responsible also for allocation and deallocation of memory, virtual memory management, etc.

What is the difference between a process and a program?

A program is a set of instructions stored on disk (passive), while a process is an instance of the program in execution (active). A single program can be associated with multiple processes.



Previous Article
Next Article

Similar Reads

Difference Between Process, Parent Process, and Child Process
Running program is a process. From this process, another process can be created. There is a parent-child relationship between the two processes. This can be achieved using a library function called fork(). fork() function splits the running process into two processes, the existing one is known as parent and the new process is known as a child. Here
8 min read
Process Scheduler : Job and Process Status
When the jobs moves through the system and makes progress, it changes it's states from HOLD to FINISH. When the job is being processed by the job manager and the process manager, it is always in one of these 5 states: HOLD: When a user submits a job and it accepts the job, the job is put on HOLD and placed in a queue. READY: A job is in READY state
2 min read
Difference between Process Image and Multi Thread Process image
1. Process Image : Process image is an executable file required during the execution of any process. It consists of several segments related to the execution of the process. Following are the contents of the process image - 1. Process Control Block 2. Stack 3. Data 4. Code 2. Multi Thread Process Image : Multi thread process image is an executable
2 min read
Process Table and Process Control Block (PCB)
While creating a process, the operating system performs several operations. To identify the processes, it assigns a process identification number (PID) to each process. As the operating system supports multi-programming, it needs to keep track of all the processes. For this task, the process control block (PCB) is used to track the process’s execut
7 min read
Process states and Transitions in a UNIX Process
Process is an instance of a program in execution. A set of processes combined together make a complete program. There are two categories of processes in Unix, namely User processes : They are operated in user mode. Kernel processes : They are operated in kernel mode. Understanding the distinction between user and kernel processes is essential for c
4 min read
Operating Systems | Process Management | Question 6
Consider the following code fragment: if (fork() == 0) { a = a + 5; printf("%d,%d\n", a, &a); } else { a = a –5; printf("%d, %d\n", a, &a); } Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE? (A) u = x + 10 and v = y (B) u = x +
2 min read
Operating Systems | Process Management | Question 6
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respecti
2 min read
Operating Systems | Process Management | Question 6
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process befo
2 min read
Multi Threading Models in Process Management
Multi threading- It is a process of multiple threads executes at same time. There are two main threading models in process management: user-level threads and kernel-level threads. User-level threads: In this model, the operating system does not directly support threads. Instead, threads are managed by a user-level thread library, which is part of t
6 min read
Introduction of Process Synchronization
Process Synchronization is the coordination of execution of multiple processes in a multi-process system to ensure that they access shared resources in a controlled and predictable manner. It aims to resolve the problem of race conditions and other synchronization issues in a concurrent system. The main objective of process synchronization is to en
9 min read
Process-Based and Thread-Based Multitasking
Multitasking operating system is an operating system that gives you the perception of two or more tasks/jobs/processes running simultaneously. It does this by dividing system resources amongst these tasks/jobs/processes and switching between the tasks/jobs/processes while they are executing over and over again. The CPU processes only one task at a
2 min read
Completion time of a given process in round robin
We are given n-processes with their completion times in form of an array. We need to find the time instant when a given process p ends if the scheduling process is round robin and time slice is 1-sec. note : Array index start with 0. Examples : Input : arr[] = {3, 2, 4, 2}, p = 1 Output : Completion time = 6 Explanation : Snap of process for every
8 min read
Communication between two process using signals in C
Prerequisite : C signal handling In this post, the communication between child and parent processes is done using kill() and signal(), fork() system call. fork() creates the child process from the parent. The pid can be checked to decide whether it is the child (if pid == 0) or the parent (pid = child process id).The parent can then send messages t
3 min read
Message based Communication in IPC (inter process communication)
Prerequisites - Cloud computing, Load balancing in Cloud Computing, Inter-process Communication In the development of models and technologies, message abstraction is a necessary aspect that enables distributed computing. Distributed system is defined as a system in which components reside at networked communication and synchronise its functions onl
5 min read
Get/Set process resource limits in C
The getrlimit() and setrlimit() system calls can be used to get and set the resource limits such as files, CPU, memory etc. associated with a process. Each resource has an associated soft and hard limit. soft limit: The soft limit is the actual limit enforced by the kernel for the corresponding resource. hard limit: The hard limit acts as a ceiling
3 min read
Process Scheduler : PCBs and Queueing
When the job scheduler accepts a job, it creates the job's PCB (Process Control Blocks) and updates it throughout the execution. These PCBs, and not the jobs, are linked to form the queues and are used to track the respective jobs. Note: The PCB store all of the data about the job being processed, like it's progress in the system. This data is need
1 min read
Two State Process Model in Operating System
Pre-requisite: States of a Process in Operating Systems The process in an operating system passes from different states starting from its formation to its completion. A process consists of program data and its associated data and a process control block (PCB). A process may change its state because of the following events like I/O requests, interru
3 min read
Formation Of Process from Program
Process: A Process is a program in execution is called as Program. But the conversion of a program into process involves various stages which are clearly defined in this article. Further more after the program is converted into the process memory has to be allocated to these process in the main memory and these memory allocations are handled by O.S
5 min read
Process Creation and Deletions in Operating Systems
Prerequisite - States of a Process in Operating Systems There are two basic operations that can be performed on a process: Creation and Deletion. They are explained as Process creation: 1. When a new process is created, the operating system assigns a unique Process Identifier (PID) to it and inserts a new entry in the primary process table. 2. Then
2 min read
Difference between Process and Kernel Thread
1. Process: Process is an activity of executing a program. Process is of two types - User process and System process. Process control block controls the operation of the process. 2. Kernel Thread: Kernel thread is a type of thread in which threads of a process are managed at kernel level. Kernel threads are scheduled by operating system (kernel mod
1 min read
Difference between Process and User Level Thread
1. Process : Process is an activity of executing a program. Process is of two types - User process and System process. Process control block controls the operation of the process. 2. User Level Thread : On the basis of level, threads are of two types: User level Kernel Level User level thread is a type of thread in which threads of a process are ma
2 min read
Message Passing Model of Process Communication
So message passing means how a message can be sent from one end to the other end. Either it may be a client-server model or it may be from one node to another node. The formal model for distributed message passing has two timing models one is synchronous and the other is asynchronous. The fundamental points of message passing are: In message-passin
3 min read
FIFO Barbershop in Process synchronization
Overview :In process synchronization, there exists a Sleeping Barber problem, as discussed here. But in the above solution, there is no guarantee that the customers are served in the order they arrive in the barbershop, i.e. there is no guarantee that the customers enter a FIFO manner(First-in First-out). In the solution discussed above. Up to n cu
5 min read
Difference between Process Contention Scope and System Contention Scope
1. Process Contention Scope :In an operating system the thread library is schedules by an operating system known as kernel thread that is managed by a thread library for user level thread to runs off an available light weight process. This is often referred to as process contention scope.Process contention scope is executed accordingly to the prior
3 min read
Difference between Routine and Process
In this article, we are going to discuss the difference between routine and process. Before differentiating between both, first, let us understand what they are. Routine :In computer programming, a routine is nothing but a sequence of code, intended for the execution of user programs and input/output operations. It can range from a subroutine, co-r
3 min read
N process Peterson algorithm
Prerequisites for this topic include an idea about synchronization among processes and how to obtain it. Also, some knowledge of the producer-consumer problems along with an idea of Peterson's algorithm is of utmost importance. Overview :Synchronization among the execution of various processes in any operating system is of utmost importance. Which
8 min read
Difference between a process stack and a CPU stack
Temporary data like as method/function arguments, return address, and local variables are stored on the process Stack, whereas on the other hand, the CPU stack consists of a collection of data words. It employs the Last In First Out (LIFO) access technique, which is the most common in most CPUs. In this article we are going to find out the detailed
3 min read
Three State Process Model in Operating System
Pre-requisites: States of a Process in Operating Systems, Two-State Process Model in Operating SystemIn this article, we'll be discussing a three-state process model in an operating system and also discussing the need for this process model, how the process executes, what will be the possible transition that can occur, and last its benefits and som
4 min read
Cooperating Process in Operating System
Pre-requisites: Process Synchronization In an operating system, everything is around the process. How the process goes through several different states. So in this article, we are going to discuss one type of process called as Cooperating Process. In the operating system there are two types of processes: Independent Process: Independent Processes a
2 min read
Six-State Process Model in Operating System
In this article, we are going to discuss the Six-State Process Model in Operating Systems and we will also understand what was the need for introducing these process models, what are the states present in these process models, and all the possible transitions that can occur in these models. Need for Six-State Process Model:The Five-State process mo
4 min read