Home >>Operating System Tutorial >Operating System Processes

Operating System Processes

Operating System Processes

Process

A method is essentially an executing process. Method execution must proceed in a sequential manner.

To put it simply, we write our computer programmes into a text file and when we execute this programme it becomes a process that executes all of the tasks specified in the programme.

When a programme is loaded into the memory and it becomes a method, it can be divided into four stack, heap, text, and data parts. The image below shows a simplified process layout inside main memory –

Operating System

Sr No Component & Description
1. Stack
The Stack process contains temporary data such as parameters for the method / function, the return address and local variables.
2. Heap
This is the memory dynamically assigned to a process during its run time.
3. Text
This involves the actual operation represented by the value of Program Counter and the contents of the registers of the processor.
4. Data
This section contains the global and static variables.

Program

A software is a piece of code that may be either a single line, or millions of lines. A computer programme is usually translated into a programming language by a computer programmer. This is a simple programme written in C programming language , for example.

#include <stdio.h>

int main() 
{
   printf("Hello, phptpoint! \n");
   return 0;
}

A computer programme is a set of instructions which perform a particular task when performed by a computer. Comparing a programme to a process helps one to infer that a process is a complex instance of a computer programme.

As an algorithm, a portion of a computer programme performing a well-defined task is called. The software is referred to as a set of computer programmes, databases, and related data.

Process Life Cycle

When a method is executed it can move through numerous states. In different operating systems these phases which vary, and the names of these states are not standardised either.

A process may usually have one of the following five states at a time.

Sr No State & Description
1. Start
This is the initial state when initiating / creating a process first.
2. Ready
The method awaits assigned to a processor. Ready processes are waiting for the operating system to assign the processor to them, so they can run. Process may enter this state after starting or running it, but may be interrupted by the scheduler to assign CPU to another process.
3. Running
If the OS scheduler has allocated the process to a processor, the process state is set to run and its instructions are executed by the processor.
4. Waiting
Process moves into the state of waiting while waiting for a resource, such as waiting for user input, or waiting for a file to be available.
5. Terminated or Exit
If the operation is complete or the operating system terminates its execution, it is transferred to the terminated state where it is waiting to be removed from main memory.

Operating System

Process Control Block (PCB)

A Process Control Block is a data structure for any process managed by the Operating System. An integer Process ID (PID) is used to define the PCB. A PCB maintains all the details necessary to monitor a process as shown in the table below-

Sr No Information & Description
1. Process State
The current state of the process, that is, if it's ready, going, waiting, or something else.
2. Process privileges
This is important if system resources are to be allowed / disallowed.
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 reference to the address of the next instruction for this method to be executed.
6. CPU registers
Related CPU registers where process needs to be stored for running state execution.
7. CPU Scheduling Information
Priority processing and other details needed for scheduling the process.
8. Memory management information
This includes page table detail, memory limits, section table depending on the operating system's memory used.
9. Accounting information
This includes the amount of Processor used to execute a process, time limits, execution ID etc.
10. IO status information
This includes a list of I/O devices allocated to the process.

A PCB 's architecture depends entirely on the operating system, which can contain different information in different operating systems. Here is a simple PCB diagram-

Operating System

The PCB is retained throughout its lifetime for a process, and will be removed once the process is over.