Breaking

Saturday, March 30, 2019


What is the Process?
A program under execution is called process. When a program is loaded to the main memory and starts its execution then it is called a process.


States of the process:-
As a process execute it changes its state. The state of a process is defined by the current activity of that process. Each process may be one of the following states:

Process State Diagram



1. New: The process is being created.
2. Running: Instructions are being executed.
3. Waiting: The Process is waiting for some event to occur(such as an I/O completion or reception of a signal).
4. Ready: The Process is waiting to be assigned to a processor.
5. Terminate: The process has finished execution.



These names are arbitrary, and they vary across the operating system. It is important to remember that only one process can be running on any processor at any instant. However, many processes may be ready or waiting.

Context Switch:-
The context switch is the computing process of storing and restoring the state of a CPU (the context) such that multiple processes can share a single CPU.the context switch is an essential feature of a multitasking operating system.


Context Switch
Context switches usually involve the following steps, assuming process p1 is running on CPU and process p2 in the next to run on CPU.
1. Store the context of p1 somewhere in memory(usually stack of p1). The context of the CPU will contain the value of registers such as the program counter, process control, and general-purpose registers.
2. Retrieve the context of p2 from memory (usually on the stack of p2) and start executing process p2.
3. After executing it store the context of p2 in memory. Then it returns to the location contained in the program counter (the line of code at which the original process was interrupted) and starts executing the process p1.
And this process is called the context switch.

Process control block(PCB):-
Each process is represented in the operating system by a process control block it is also called task control block.

Imagine there are certain processes running in a system. If one process is going for I/O operation or in waiting state and CPU is assigned to some another process(context switch). Now when the process has to resume the system needs some information to execute from that location from where the process is interrupted. so that kind of information stored in the Process control block.

It contains many pieces of information associated with a specific process, including state, number,etc..

PCB with Process Table

1. Process state:-
The state may be New, Ready, Running, Waiting, Halted, and so on.

2. Process Number:- It is the Id of the process.
3. Program Counter:- The counter indicates the address of the next instruction to be executed for this process.
4. CPU register:- Registers vary in number and type depending on the computer architecture. they include accumulator, index register, stack pointer, and general-purpose registers, plus any condition code information. Along with the program counter. this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward.
5. CPU scheduling information:- This information includes a process priority, pointer to scheduling queues, and any other scheduling parameters.
6. Memory Management Information:- This information may include such information as the value of the base and limit register, the page tables (or the segment tables, depending upon the memory system used by the operating system).
7. Accounting Information:- This information includes the amount of CPU and real-time used, time limits, account number, job or process number, and so on.
8. I/O status information:- This information includes the list of I/O devices allocates to the process, a list of opening files, and so on.

Also, Read 👇



WHAT IS VIRTUALIZATION 😨..? [ CLEARLY EXPLAINED ]

close