Home »
Operating System
Process in Operating System: Classification, Scheduling, Execution
In this tutorial, we will learn about the process in operating system, its classification, scheduling, and execution.
By Prerana Jain Last updated : May 06, 2023
Process in Operating System
In the operating system, there are numerous task and application program run simultaneously. A program is stored in the hard disk or any other form of secondary storage. When the program is executed it must be loaded in the system’s memory. A process can be viewed as a program in execution. In the system, each process is assigned a unique Id when it is created and it will be referenced by the unique Id until the process completes execution and it is terminated. A process is an entity which performs the basic unit of work or one work at a time. We can say that a process is an instance of a computer program that is being executed. A process contains the program code and the activity that is going to be performed. when the computer program is in secondary memory then it is a passive entity or when a process is in main memory then it is an active entity. In the system, several processes may be associated with the same program.
A process held a number of attributes like hardware, memory, CPU, and progress.
Process Classification
A process can be broadly categorized into the following two types based on its execution:
1. I/O-Bound Process
An I/O-bound process is a process whose execution time is determined mainly by the amount of time it spends completing I/O operations.
2. CPU-Bound Process
A CPU-bound process is a process whose execution time is determined by the speed of the CPU it runs on. A CPU-bound process can complete its execution faster if it is running on a faster processor.
Note: There is a third category - Memory-bound process. However, since RAM serves as I/O for the processor, this can be considered as an instance of the I/O-bound process type.
Process Classification Based on Execution Mode
Further a process can be broadly categorized into the following two types based on execution mode.
1. Kernel Mode
In the kernel mode, a process has unrestricted access to the system hardware it can execute privileges instruction and can access both user and kernel address space.
Example: Most of the device drivers in the system execute as kernel mode processes.
2. User Mode
In the user mode it has no direct access to the underlying system hardware it can only access its own user address space of other processes and it cannot execute privileged instructions.
Example: web- browser is executed as a user- mode process.
Process Scheduling in Operating System
On a computer system, there are often numerous processes that need to be executed simultaneously. Furthermore, the requests for resources necessary for their execution are made asynchronously. Therefore, to handle competing requests for resources including the processor, the OS employs a process scheduler. The process scheduler assigns each process the necessary resources and its turn for execution on the CPU. The decision to schedule a process is made by a scheduling algorithm.
The scheduler maintains three queues, to schedule the processes.
- Job queue: The job queue is the set of all processes on the system.
- Ready queue: The ready queue has all the processes that are loaded in main memory. These processes are ready and waiting for their turn to execute as soon as the CPU becomes available.
- Device queue: The set of processes waiting for an I/O device to become available, such as a printer. This queue is also known as the Blocked Queue.
Process Execution in Operating System
When a program is loaded into the memory (process memory) and it becomes a process and it can be divided into four sections, stack, heap, text and data.
1. Stack
The stack is used for local variables when the local variables are declared in the memory of some spaces on the stack is reserved for them.
2. Heap
The heap is used in the system for the dynamic memory allocation and it is managed by calls to new, delete, malloc, free like commands.
3. Data Section
The data section is made for of the global and the static variables when it is allocated and initialized prior to executing the main function.
4. Text Section
The text section is made for the compiled program code when the program is launched it is read from non-volatile storage in the system.
Conclusion
A process is not itself a process it is actually a passive entity so its content is stored in the hard disk whereas a running process is a passive entity so the program counter counts the next instruction to be executed. In the system, two processes may be linked with the same program and these process cannot be considered as two separate processes. For any instances, many users may be running at the main program.