Greetings!We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at firstname.lastname@example.org.
In the previous post, we have already seen what a process? How a process does looks like etc.
Now, we will see different attributes of a process, process control block, and different states of a process. At last, we will see difference between scheduler and dispatcher.
Attributes of process
Each process has a unique identification so with the help of these attributes we can easily identify the process.
(1) Process id: – A unique identifier or number assigned by operating system.
(2) Program counter: – Program counter is a register in the computer which has the address of the next instruction to be executed from memory.
(3) Process state: – The process from its creation to completion goes through various states such as new, ready, running and waiting.
(4) Priority: – Every process has its own priority. The process which has highest priority CPU will take first that process.
(5) General purpose registers: – Every process has its own registers which are used to hold data during the execution of the process.
(6) List of open files: – Every process uses some files which need to be present in the main memory. OS maintains list of open files in the PCB.
(7) List of open devices: – OS maintain the list of open devices which are used during the execution of process such as printer, scanner and hardware devices etc.
(8) Protection: – OS maintain unique workspace for each process. We are not supposed to get into the other process workspace.
Process Control Block
Below picture depicts a process control block –
Every process will get one process control block. If there are more than one process, then, PCB also will be more than one according to the process and all the PCB will be in link list.
States of a process
When a process executes, it passes through different states. States of a process are as following-
New: – This is the initial state where process is about to create.
Ready: – After creation of process, the process enters in the ready state and it waits for the CPU to be assigned.
Running: – The process is running under the CPU and program is executing by the CPU
Waiting: – When the process request to I/O then it enters in the wait state. It executes in the main memory and doesn’t require CPU.
Terminated or exit: – When the process finishes its execution or it its terminated by operating system, it is moved to terminated state.
Dispatcher: – Dispatcher is one of the important entity in CPU scheduling. A dispatcher is placed in between the ready queue and Short-term scheduler.
When the short-term scheduler makes decision that which process from among the several processes waiting in the ready queue will be allocated CPU next for its execution, it is the dispatcher that assigns CPU to that selected process.
Dispatcher Latency: – dispatcher latency is the amount of time taken by the system to stop one process
Difference between scheduler and dispatcher
Consider a scenario, there are n processes in ready queue. They all arrived a particular timing. We will Choose a particular process basis of scheduling algorithm. Like we choose FCFS algorithm, so according to FCFS scheduler will take P1 process for execution. Now, dispatcher takes P1 to running state.
– Scheduler will select the process from ready queue and dispatcher will load the new process into the CPU.
– Dispatcher is also responsible for context switching, switch to user mode and jumping to proper location when process again restarted.
That’s end of this post. Till now, we have seen different attributes of a process, different states of a process, process control block, and difference between schedular and dispatcher. In the next tutorial, we will learn about process schedular.