Processes In Operating Systems

Thormiwa
3 min readJun 24, 2023

--

In an operating system, we can say a process is an instance of a running program. The execution of a process must move in a sequential method. Each process runs in its own isolated environment and operates independently of other processes.

Let’s break down processes into a few concepts…

  1. Process Creation: A process is created by the operating system to execute programs. When an app is launched, the operating system creates a new process to run the app.

Let’s think of the process creation like you open the chrome app on your laptop. The operating system creates a new process specifically for that web browser, which will handle all the tasks related to browsing the internet.

2. Process States: A process can exist in different states throughout its lifecycle , the following are the most common ones:

Running: The process is currently being executed by the CPU.

Ready: The process is waiting to be assigned to the CPU for execution.

Blocked/Waiting: The process is waiting for an event (such as user input or I/O operation) to occur.

Terminated: The process is no longer running, and its resources are freed up for reuse by other processes.

I think a fair example to use for this is the File download process, Initially it is in a running state downloading the file, if it runs into an error or it needs a password to download a content of the file , it moves to the waiting state, waiting for the user to respond, Once the user provides the necessary input, the process moves back to the ready state and eventually resumes execution, till the download is over and the process is terminated.

3. Process Scheduling: Process scheduling refers to the mechanism by which the operating system determines which processes should be allocated CPU time. Scheduling Algorithm is used by the operation system to make use of the available CPU resources and ensure fairness among processes.
Imagine you have multiple processes running simultaneously on your computer, such as a chrome, spotify, and whatsapp. The operating system decides how much CPU time each process should receive, taking into account factors like priority, time slice allocation, and system load. This ensures that all processes have a fair chance to execute and that the computer remains responsive.

4. Process Control Block (PCB): This is an important data structure used by the operating system to manage and keep track of each process. It contains information about each process, allowing the operating system to manage and control the execution of processes effectively.

On Linux, to get the list of running processes, you can use the lsof -i command, to kill/stop a specific process you can use the kill -9 PID command, where PID is the process id, it is usually an integer e.g 267, 23421 you can get it from the list of processes running.

When a process is scheduled to run, the operating system retrieves the corresponding PCB from its process table to obtain the necessary details and context for execution. When a process is scheduled out or suspended, the PCB is updated with the process’s current state and relevant information before being stored.

Think of the PCB as a file that holds important information about a process, just like a student file holds details about a student in a classroom. The PCB stores information such as the process ID, current state, program counter (next instruction), CPU registers, memory management details, resource allocations, and scheduling information. It helps the operating system manage and control processes effectively.

I hope these simplified examples will help you understand Processes in Operating Systems a lot better as it did for me.

Thanks for Reading :)

--

--