Operating system Notes

mobiprep (6).png

Introduction of Operating System

mobiprep (6).png

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

mobiprep (6).png

Scheduling

mobiprep (6).png

Threads

mobiprep (6).png

Memory Management

mobiprep (6).png

File Management

mobiprep (6).png

Synchronization

mobiprep (6).png

Disk Management

mobiprep (6).png

IO Management

mobiprep (6).png

Protection And Security

Heading

Q

1

What is a process?

LRM_EXPORT_207556595493866_20190724_1939

Ans

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:
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.

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.

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)

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.

LRM_EXPORT_207556595493866_20190724_1939

Q

2

Explain different types of process present in os.

LRM_EXPORT_207556595493866_20190724_1939

Ans

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.

LRM_EXPORT_207556595493866_20190724_1939

Q

3

Explain various process states.

LRM_EXPORT_207556595493866_20190724_1939

Ans

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.

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.

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.

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

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.

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.

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.

LRM_EXPORT_207556595493866_20190724_1939

Q

4

What is PCB.Explain its significance.

LRM_EXPORT_207556595493866_20190724_1939

Ans

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.
Process id
When a process is created, it is assigned a unique id. This is called process id.

Process state
This field mentions the current state of the process.

Process priority
This field mentions the priority of the process

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

Significance of PCB
As the PCB keeps track of all the processes, it is very much useful is multiprogramming.
It gives a detailed account on the resources used by the process.
It records the execution status of the process.

LRM_EXPORT_207556595493866_20190724_1939

Q

5

What role does operating system plays in process management?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The following are the different tasks performed by the operating system in process management:
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.
Resource allocation
The operating system allocates and deallocates the resources to the processes according to their requirement.
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.
Deadlock handling
When a deadlock occurs, the operating system takes steps to recover from the deadlock. Hence, the OS is involved in deadlock handling.

LRM_EXPORT_207556595493866_20190724_1939

Q

6

Explain various types of schedulers in an os?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The different types of schedulers are explained below:
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.
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.
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.

LRM_EXPORT_207556595493866_20190724_1939

Q

7

What is the difference between I/O bound and CPU bound process?

LRM_EXPORT_207556595493866_20190724_1939

Ans

LRM_EXPORT_207556595493866_20190724_1939

Q

8

Explain Context Switch, Synchronization, dispatch latency

LRM_EXPORT_207556595493866_20190724_1939

Ans

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.

LRM_EXPORT_207556595493866_20190724_1939

Q

9

What are the different ways of resource sharing between parent and children processes?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The following are the different methods of resource sharing between the parent and the child processes:
a.Parent and child share all the resources
b.Child shares a subset of parent’s resources.
c.Parent and child do not share any resources

LRM_EXPORT_207556595493866_20190724_1939

Q

10

What do you understand by System calls?

LRM_EXPORT_207556595493866_20190724_1939

Ans

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.

LRM_EXPORT_207556595493866_20190724_1939