View Course Path

Processes in Operating Systems

What is a process?

In an operating system, a process can be defined as an entity that represents the basic unit of work to be implemented in the system. When a user boots up a PC, many processes are started unknown to the user.

Some of the most common processes are as follows.

  1. A process that waits for incoming email.
  2. A process that runs on behalf of an anti-virus to check for viruses periodically.
  3. Browsing the web is also a process.
  4. Printing files is also a process.

You probably get an idea of what a process is.

Activity: Write down ten other processes in the comment section. For a challenge, name 5 background processes and 5 foreground processes.

However, at any instant of time, the CPU is running just one process in a multiprogramming system. But the CPU jumps around from one process to another in such quick succession, it gives the feeling of executing both processes simultaneously. This illusion of parallelism is called pseudoparallelism.

What is the Process Model?

When a program is loaded into memory, it becomes a process, which can be divided into four sections, namely, stack, heap, text, and data.

The ‘stack’ contains the temporary data of the program such as function parameters, return address, etc. The ‘heap’ is a dynamically allocated memory to a process during its time of execution. ‘Text’ includes the current activity of the process and the ‘Data’ section contains the global and local variables.

Now, in our computers, many processes need to be executed simultaneously, so to make the execution of every process smooth and efficient, the operating system organizes all the runnable software on the computer into several sequential processes, allotting each process its own virtual Central Processing Unit (CPU). This whole organization of processes is termed as a Process Model.

Process Creation

There are different operations in the system for which a process can be created. Some of the events that lead to process creation are:

  • User requests to create a new process
  • System initialization
  • Batch job initialization
  • A running process requires the creation of another process using a system call.

A process may be created by another process using the fork() method. The process which calls the fork() method or simply, the process creating another process is known as the parent process and the created process is called a child process. A child process can have only one parent, but a parent process can have multiple child processes. Also, both the parent and child processes have the same memory, open files, and environment strings, but they have distinct address spaces.

process creation using fork


Process Termination 

Process termination occurs when a process is simply terminated. The exit() system call is used to terminate a process. Now, a process can be terminated because of various reasons. They can be categorized into two different categories, voluntary and involuntary. Some of the causes of process termination are:

  • A process may be terminated naturally after its execution releasing all of its resources.
  • A child process may be terminated if its parent process requests for the same.
  • A process can be terminated if it tries to use a resource that it is not allowed to.
  • Another cause of a process termination can be an I/O failure for a process.
  • If a parent process is terminated, then it will be another cause for its child process’s termination.
  • A process can also be terminated if it requires more memory than what is currently available in the system.

Why do processes terminate?

  1. Most processes terminate because they have done their work. Processes after completing their work, perform a system call to tell the Operating System that they have completed the work. In UNIX, this system call is ‘exit’. In Windows, this goes by ‘EndProcess’. For the foreground processes, the user has a clickable icon to exit the process. It’s usually denoted by the x symbol for windows or the red button in macOS.
  2. There may be some instances where the processes exit involuntarily. This may be due to some fatal error. For example, if you command the compiler to compile a file called red.c but no such file exists, the compiler will terminate.
  3. Sometimes the process causes an error due to which it has to terminate. These errors include, but are not limited to:
    – Referencing nonexistent memory
    – Divide by zero error
    – Executing an illegal instruction
    In some cases, the process signals the operating system that it wishes to handle the error itself using an interrupt.
  4. There are some processes that instruct the OS to kill other processes. In UNIX, this command is straightforward – ‘kill’. Anyway, the killer must have the necessary authorization to kill the other process.


Process Hierarchy

In a computer system, we require to run many processes at a time and some processes need to create other processes whilst their execution. When a process creates another process, then the parent and the child processes tend to associate with each other in certain ways and further. The child process can also create other processes if required. This parent-child like structure of processes form a hierarchy, called Process Hierarchy.

Unlike sexual reproduction though, the child processes have only one parent. A process can be a parent by itself and that is usually the case.

In UNIX, a process and all of its children and grandchildren form a process group. When a user sends a signal from the keyboard, the signal is delivered to all members of the process group currently associated with the keyboard. Individually, each process can catch the signal and do as it wishes.

There is no hierarchy system in Windows. Each process is treated equally. The only remote association with the hierarchy that it does is that a parent process gets a handle. But then again, this parent process can pass the handle to some other process thereby invalidating the hierarchy system.

Two-State Process Model

A Two-State Process Model categorizes a process in two categories:

  1. A process running on CPU
  2. A process not running on CPU

When a process is created, it is in the not in running state and when the CPU runs the process, it is in the running state. If there is a process in a running state and another process is created with a higher priority, then the newly created process will be run by the CPU. The former process will go in the not running state.

Five-State Process Model

The Five-State Process Model categorizes a process in five states:

  1. New: When a process is newly created, it is said to be in the new state.
  2. Ready: All those processes which are loaded into the primary memory and are waiting for the CPU are said to be in ready state.
  3. Running: All the processes which are running are said to be in the running state.
  4. Waiting: All the processes, which leave the CPU because of any reason (I/O or for any high priority process) and wait for their execution, are in waiting state.
  5. Terminated: A process that exits or terminates from the CPU and the primary memory is said to be in the terminated state.

5 state process model

Implementation of Processes

To implement the process table, the operating system maintains a table called the process table, with one entry per process.

The process table is a data table which is used by an operating system to keep track of all the processes present in the system. The entries in the table tell about the information about the states of the processes, their program counters, stack pointers, allocated memories, the status of their files and their accounting and scheduling information. They contain every information about the present processes and also, of those processes which are switched with the current processes.

Some of the fields of a typical process table is given below.

Process Management Memory Management File Management
Registers Pointer to text segment info Root directory
Program counter Pointer to the data segment info Working directory
Program status word Pointer to stack segment info File descriptors
Stack pointer User ID
Process state Group ID
Scheduling parameters
Process identity
Parent process
Process group
Time when process started
CPU time used
CPU time of children
Time of next alarm
Related courses for this will be up soon!

2 thoughts on “Processes in Operating Systems

  1. Background processes:-
    *process of system update(OS)
    *Process of BIOS Check
    *Process of System storage( HDD or STD) error check
    *Process of System Notifications
    *Process of Auto save in Microsoft Office(MSWord).

    Foreground Processes:-
    *Process of playing games
    *Process of downloading software
    *Process of editing pictures and videos on both adobe photoshop and premiere
    *Process of typing on Microsoft word
    *Process of Creating graphic design on coral draw.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.