(OS) Unit-2.1 Process
(OS) Unit-2.1 Process
1
Process Concept
• A process contains
2
Process vs Program
• program is a group of instructions to carry out a specified task.
• A program is a passive entity, for example, a file accommodating a group of
instructions to be executed (executable file).
• Program is stored on disk in some file and does not require any other
resources.
• When a program is executed, it is known as process.
• It is considered as an active entity and realizes the actions specified in a
program.
• Process holds resources such as CPU, memory address, disk, I/O etc.
• Multiple processes can be related to the same program. It handles the
operating system activities through PCB (Process control Block) which
includes program counter, stack, state etc
• A web browser launches multiple processes, e.g., one per tab 3
• Text section is made up of the compiled
program code, read in from non-volatile
storage when the program is launched.
• The Data section is made up the global
and static variables, allocated and
initialized prior to executing the main.
• The Heap is used for the dynamic
memory allocation, and is managed via
calls to new, delete, malloc, free, etc.
Process in Memory
• The Stack is used for local variables.
Space on the stack is reserved for local
variables when they are declared.
4
The Process Model
Figure 3-1. (a) Multiprogramming of four programs. (b) Conceptual model of four
independent, sequential processes. (c) Only one program is active at once.
5
• Conceptually, every process has its own virtual CPU but in reality CPU switches back
and forth from process to process.
• This Rapid switching back and forth is called "Multi-Programming.“
Multi-Programming
• In this there is 4 program in memory. We have single shared processor by all programs.
• There is only one program counter all programs in memory. In this program counter is
initialized to execute the part of program A then with the help of process switch it transfer
control to program B and execute some part of this.
• After that program counter for program C is active and execute some part of it and so
onto program D. Then all the steps continuous may be randomly with the help of process
switches until all program is not completed.
One Program At One Time
• At any given instant only one process run and other process after some interval of time.
• In other point of view all processes progress but only process actually runs at given
instant of time.
6
Process States
7
Five state process models
8
New : The process is being created.
9
Process suspension
• Many OS are built around (Ready, Running, Blocked) states. But there is
one more state that may aid in the operation of an OS - suspended state.
• When none of the processes occupying the main memory is in a Ready state,
OS swaps one of the blocked processes out onto to the Suspend queue.
10
Process State Transition Diagram
11
Process Control Block(PCB)
12
CPU registers - general purpose registers, index registers, stack pointer
etc.
CPU scheduling information - This information includes a process
priority, pointers to scheduling queues, and any other scheduling
parameters.
Memory Management information - This information may include such
information as the value of the base and limit registers, the page tables, or
the segment tables, depending on the memory system used by the
operating system.
Accounting information - This information includes the amount of CPU
and real time used, time limits, account numbers, job or process numbers,
and so on.
I/O Status information - This information includes the list of I/O devices
allocated to the process, a list of open files, and so on. 13
Process Creation
Events which cause process creation:
• Address space
• Resource sharing
14
Process Hierarchy
• Modern general purpose operating system used to create and destroy
processes. A process may create several new processes during its time of
execution.
• The creating process is called "Parent Process", while new processes are called
"Child Processes".
16
Process Termination
Events which cause process termination:
17
Implementation of Processes
18
19
There are many following queues:
• Read Queue: This queue is used for storing the processes with state ready .
• Blocked Queue: it is used for storing the processes but need to wait for an
input output device or resource.
• Suspended Queue: It is used for storing the blocked process that have been
suspended.
• Free process Queue: it is used for the information of empty space in the
memory where a new PCB can be created.
20
Figure. Some of the fields of a typical process-table entry.
21
Implementation of Processes
Figure 3-5. Skeleton of what the lowest level of the operating system does
when an interrupt occurs.
22