Process | Operating System Notes | B.Tech
top of page

Process: Operating System Class Notes

Updated: Oct 16, 2022

Mobiprep has created last-minute notes for all topics of operating system to help you with the revision of concepts for your university examinations. So let’s get started with the lecture notes on Operating System (OS).

Our team has curated a list of the most important questions asked in universities such as DU, DTU, VIT, SRM, IP, Pune University, Manipal University, and many more. The questions are created from the previous year's question papers of colleges and universities.


PROCESS: Program to process, Lifecycle of the process, Process control block, IPC


Question- 1) What is a process?

Answer: A program in execution is called a process. A program becomes a process when it is loaded into the main memory for execution. A process is the basic unit of execution in a computer system. It is an ‘active’ entity, while program is a ‘passive’ entity.

A process is divided into four segments in the memory. The memory layout of a process is given below:


Process in Operating system

  1. Stack- Stack is used to store temporary data such as return address, local variables and function parameters. The return address is the address of the instruction which has to be executed after the completion of function execution. The stack grows from lower address to higher address and it follows the LIFO mechanism.

  2. Heap- Heap is used for dynamic memory allocation. It is used to allocate memory to the variables while the execution of a process. It is used by the malloc() and calloc() functions.

  3. Data- The data section is used to store the global and static variables. This region remains static throughout the process execution. It is also called BSS (Block Started by Symbol)

  4. Text- This region stores the instructions in the process. It is also called the Code Segment. It stores the values in the CPU registers and the program counter.


 

Question- 2) Explain different types of process present in OS.

Answer: The processes can be divided into two broad classes. They are:

  1. Independent process- Independent processes do not depend on each other. i.e. one process cannot affect another process. These processes do not share their data with each other or with the system.

  2. Co-operative process- Cooperative processes depend on each other for execution. They share data with the other processes. The execution of such processes is affected by the other processes in the system.


 

Question- 3) Explain various process states.

Answer: The different states of a process are explained in the diagram given below.


Various process states in operating system

1) New

This state is the initial state of every process that is being created. Whenever a process is created, the process is in the New state.


2) Ready

When a process is ready to run, it enters the Ready state. i.e. when a process is loaded into the main memory and is waiting to be executed by the processor, the process remains in the Ready state.


3) Ready Suspended

A process is in the ready suspended state when it is moved into the secondary memory from the main memory due to lack of storage space. When there is no sufficient space in the main memory for the process, the process is suspended and moved to the secondary memory. This state of the process is called the ‘ready suspended’ state.


4) Running

When the process is being executed, it is in the ‘running’ state.


5) Blocked or wait

The process is in the ‘wait’ state when it requests for I/O access from the processor. The process remains in the wait state until the I/O operation is complete. Once the I/O operation is over, the process returns to the ‘ready’ state.


6) Blocked Suspended

This state is similar to the ‘ready suspended’ state except for the fact that the process is suspended when that process is in ‘blocked’ state. i.e. when the process is waiting for an I/O operation to be complete.


7) Terminated

If the process has completed its execution, it enters this state. Once the process is terminated, the PCB of the process is deleted and the process is deleted from the main memory.


 

Question- 4) What is PCB. Explain its significance.

Answer: The Process Control Block (PCB) contains information about the process. It contains the information about the execution status of the process. The operating system uses the PCB to keep track of all the processes in a multiprogramming system.


Whenever a process is created, a PCB is also created for that particular process. The PCB contains the information about the process id, program counter, process state, priority etc., When the process is transferred from one state to another, the data is updated in the PCB.


PCB in operating system

1) Process id

When a process is created, it is assigned a unique id. This is called process id.


2) Process state

This field mentions the current state of the process.


3) Process priority

This field mentions the priority of the process


4) Program counter

Program counter contains the address of the next instruction to be executed.


Significance of PCB

  1. As the PCB keeps track of all the processes, it is very much useful is multiprogramming.

  2. It gives a detailed account on the resources used by the process.

  3. It records the execution status of the process.


 

Question- 5) What role does operating system plays in process management?

Answer: The following are the different tasks performed by the operating system in process management:

1) Process scheduling

The operating system decides the order of execution of the processes. The process scheduling is done based on the process priority. The OS also decides the execution time of the process.

2) Resource allocation

The operating system allocates and deallocates the resources to the processes according to their requirement.

3) Traffic control

The operating system keeps track of the states of a process. It allocates and deallocates the processes to the processor. Hence, the OS is called a traffic controller.

4) Deadlock handling

When a deadlock occurs, the operating system takes steps to recover from the deadlock. Hence, the OS is involved in deadlock handling.


 

Question- 6) Explain various types of schedulers in an OS?

Answer: The different types of schedulers are explained below:

1) Long term scheduler

The long term scheduler controls the degree of multiprogramming. It selects the processes for execution such that the CPU utilization is maximized. Hence, the long term scheduler directly determines the efficiency of a system.

The main job of the long term scheduler is to load the programs from the disk to the primary. It selects the I/O and CPU bound processes from the disk such that the CPU is utilized efficiently.

2) Medium term scheduler

The medium term scheduler is responsible for swapping the processes in and out of the main memory. It suspends and resumes the execution of the processes. It is helpful in reducing the degree of multi-programming of the system.

3) Short term scheduler

The short term scheduler is used to assign the processes in the ready state for execution. It decides the order in which the processes must be executed.

It is called a short term scheduler because it executes more frequently than the other schedulers. This is due to the fact that the processes take only a few milliseconds for execution.


various types of schedulers in operating system

 

Question- 7) Explain Context Switch, Synchronization, dispatch latency.

Answer:

Context Switching

Context switching is the process which is done when the processor switches from one process to another. The context of one process is saved and the context of another process is loaded into the memory. The context of a process refers to the data in the program counter, and CPU registers at that instance of time.

In other words, the process of changing the state of a process from ‘running’ to ‘ready’ is called context switching.

Synchronization

Process synchronization refers to the sharing of resources between processes, without causing any inconsistency. The main aim of process synchronization is to maintain data consistency in the system and to prevent race condition.

It is very much required when the processes have to be executed concurrently. It is used to achieve the coordination of process interactions in the computer system.

Dispatch Latency

The dispatch latency is the time taken by the dispatcher to stop one process and start another.

The dispatcher is responsible for moving the process from the ready state to the running state. It gives the CPU control to the process. The time taken by the dispatcher in this process is called dispatch latency.


 

Question- 8) What are the different ways of resource sharing between parent and children processes?

Answer: The following are the different methods of resource sharing between the parent and the child processes:

  1. Parent and child share all the resources

  2. Child shares a subset of parent’s resources.

  3. Parent and child do not share any resources


 

Question- 9) What do you understand by System calls?

Answer: The system call acts as an interface between the user program and the operating system. The user program requests a service from the OS kernel through a system call. System calls are used for process management, file management, resource management etc.,

The system calls are usually assembly language programs which directly communicate with the kernel.


system calls in operating system

 

Question- 10 What is the difference between I/O Bound and CPU bound process?

Answer:

I/O Bound Process

CPU Bound Process

  • I/O bound process requires more I/O time

  • CPU bound process requires more CPU time

  • ​Has long I/O cycles and short CPU cycles.

  • Has short I/O cycles and long CPU cycles.

  • Spends more time in ‘waiting’ state

  • Spends more time in ‘running’ state

  • ​The ready queue will always be empty.

  • The I/O waiting queue is always empty.

  • Short term scheduler has a little role to play.

  • ​The I/O devices are not used.


 

Question- 11) Enlist any five system calls with their significance.

Answer:

a. Fork()

The fork() system call is used for the creation of a new process(child) from an existing process (parent). The child process will be a copy of the parent process. The child process uses the same registers, program counters as that of the parent process.


The fork() system call returns an integer value. If the returned value is a negative integer, it means that the process creation is unsuccessful. Zero is returned in the child process. If the returned value is positive, it indicates the address of the child process.

b. Exit()

The exit() system call is used by the process when it completes its execution. When the process finishes its execution, it asks the OS to delete it from the memory using the exit() system call.

c. Exec()

The exec() system call us used to replace the current process with another process. If a process calls the exec() system call, the data of that process is lost and is replaced by another process.

d. Read()

The read() system call is used by the process when it wants to read the data from a file.

e. Write()

The write() system call is used to write the data in the buffer to a device or a file. It is similar to the printf() function in C language.


 

Question- 12) When is a process known as orphan or zombie?

Answer:

Orphan Process

When a running process’s parent does not exist, the process is called an orphan process. i.e. if a process does not have a parent process (or) if a process’s parent has completed its execution and terminated, the process is called an orphan process.

Zombie Process

A zombie process is a process which has terminated, but still remains in the process table. This happens when the parent process does not pick up the terminated child process’s exit code.

A zombie process can be removed only when the parent process picks up the child process’s exit code.


 

Question- 13) Explain the use of WAIT() and ABORT() system calls?

Answer: Wait()

The wait() function call is used to terminate the process immediately.

SYNTAX

Void exit (int status_value);

The exit() function stops the execution of the process abruptly and returns the status value to the parent process.

EXAMPLE

#include <stdio.h>
#include <stdlib.h>
int main() {
   printf("Before executing exit()”);
   exit(0);
   printf("After calling exit()");
   return 0;
}

OUTPUT

Before executing exit()

We see that the portion of the code after the exit function is not executed.


Abort()

The abort() system call is used to stop the execution of a process in an abnormal way. Usage of the abort() system call to terminate a process is not recommended.

Example:

A C program which uses the abort() function is given below.

C Code:

#include <stdio.h>
#include <stdlib.h>
int main() {
   printf("Before calling abort()”);
   abort();
   printf("After Calling abort()");
   return 0;
}

Output

Before calling abort()

Explanation

In the above example, we see that the part of the program after the abort() function is not executed. Once the abort() function is called, the process is terminated.


 

Question- 14) Explain various models of inter-process communication.

Answer: The two models of inter-process communication are:

  1. Shared memory

  2. Message Passing

Shared Memory

In this method, the processes communicate with each other through a shared memory. Shared memory is a memory that can be accessed by multiple processes at the same time. This method is the fastest method of inter-process communication.

When process A has to send data to process B, process A puts the data in the shared memory. After this, the process B takes the data from the shared memory.

shared memory in operating system

Message Passing

In message passing, the processes are not directly connected to each other. Rather, they place the data to be shared in a message queue.

The sender places its data in the message queue, and the recipient retrieves the data from the queue. The data remains in the queue until the receiver retrieves it.

This method is easy to implement, but it is slower than the shared memory model.


message passing in operating system

 

Question- 15) Differentiate between direct and indirect communication.

Answer:

Direct communication

Indirect communication

  • The sender process names the recipient process during communication.

  • The sender process sends the data to an intermediary mail box instead of directly naming the recipient process.

  • A communication link is established between the sender and the recipient processes.

  • The sender and the recipient processes share a mailbox.

  • Can associate with only one process

  • Can associate with more than one processes

  • ​Send message:

send(X, message)

(X is the receiver)


  • Send message:

Send(A, message)

(A is the mailbox)

  • Receive message:

Receive(Y, message)

(Y is the sender)


  • Receive message:

Receive(A,message)

(A is the mailbox)







 

Question- 16) Which systems allow only one process execution at a time?

Answer: A uni-programming system allows only one process to execute at a time. Such systems allow only one program to reside in the main memory. All the available resources in the system are provided to that process. The structure of a uni-programming system is given below:


uni-programming in operating system


 

Question- 17) How can a process be terminated?

Answer: The process can be terminated in one of the following ways:

a. Normal completion

Once the last instruction of a process is executed, the process is terminated by an exit() system call.

b. Time limit exceed

When a process takes longer time to execute than the specified time, the process is terminated by the operating system.

This condition mostly occurs in user-interactive processes.

c. Unavailability of memory

A process is terminated if there is insufficient space in the main memory for the process. The process is terminated because, the OS cannot allot the memory required by the process.


 

Question- 18) What is ready state of a process?

Answer: When a process is loaded into the main memory and is waiting to be executed by the processor, the process is in the Ready state. The processes in the ready state are waiting for the allocation of CPU.


 

Question- 19) What is inter-process communication?

Answer: Inter-process communication is the process which enables the communication between the processes. This is done to ensure cooperation between the processes which are executed concurrently. IPC is used to synchronize the processes. Different processes can communicate with each other through a shared memory or by message passing.


 



Recent Posts

See All
bottom of page