Swami Keshvanand Institute of Technology,
Management & Gramothan
Department of Information Technology
Process
5IT4 – 03
Credits – 03
MEHUL MAHRISHI
ASSOCIATE PROFESSOR
DEPARTMENT OF INFORMATION TECHNOLOGY
PROCESS A
PROCESS B PROCESS C
Progra
m
(hello.c
)
Kernel
Space
User
gcc
hello.
Space
c
./
Executable [Link]
([Link]) Process
gcc
Executes
hello. in RAM
c
Stored on
secondary
disk
all processes eventually map their kernel space in the RAM.
This means is that we have just a single copy of the kernel
present in the RAM.
However, there can be multiple identical entries for each
processes in the kernel code and data.
Corresponding to each process, the kernel stores some metadata
Process Control Block
The operating system typically performs several operations when it creates a
process.
First it must be able to identify each process; therefore, it assigns a process
identification number (PID) to each process.
Next the operating system creates the PCB/Process Descriptor which
maintains information about the process (that required for Operating System).
If the operating system supports multiprogramming, then it needs to keep
track of all the processes.
For each process, its process control block (PCB) is used to track the process’s
execution status.
This block of memory contains information about process state, program
counter, stack pointer, status of opened files, scheduling algorithms etc.
All these information is required and must be saved when the process is
switched from one state to another.
Structure of PCB
PCB
Process States
How a Process is created &
Deleted?
A process may create several new processes, via a system call,
during the course of execution.
In Unix the system call is fork() and in windows it is createprocess().
The creating process is called a parent process, and the new
processes are called the children of that process.
Each of these new processes may in turn create other processes,
forming a tree of processes.
Most operating systems (including UNIX and the Windows family of
operating systems) identify processes according to a unique
process identifier (Pid)
A process is deleted through exit() system call in Unix and
terminateprocess() system call in windows systems.
Process Scheduling
The objective of multiprogramming is to execute multiple process at a
time to maximize CPU utilization.
The objective of Time Sharing is to switch CPU among the processes so
frequently that the user can interact with multiple programs
simultaneously.
To meet these tasks, process schedulers are used.
There are 3 types of scheduler:
Long Term Schedulers: The processes are spooled to a mass storage device
for later execution. The work of this scheduler is to select one of the these
processes and bring them into main memory.
Not many processes can be stored in the memory that are waiting for
execution. This is the task of long term scheduler to put a check on Degree of
Multiprogramming (number of processes in the main memory).
Medium Term Scheduler: To reduce the degree of
multiprogramming, some system introduces such schedulers that
swap out the extraneous process from the memory.
Later these processes are swapped back into the memory as per
the availability.
Short Term Schedulers/CPU Scheduler: Selects one of the
process that is ready to execute and grant CPU to it.
Two other important terms: Dispatcher
Dispatcher: is a special program which comes into play after the
scheduler.
When the scheduler completes its job of selecting a process, it is
the dispatcher which takes that process to the desired state/queue.
The dispatcher is the module that gives a process control over the
CPU after it has been selected by the short-term scheduler. This
function involves the following:
Switching context
Switching to user mode
Jumping to the proper location in the user program to restart that
program
Two other important terms:
Queues
There are different queues of processes (in an operating system):
Job Queue: Each new process goes into the job queue. Processes in the job
queue reside on mass storage and await the allocation of main memory.
Ready Queue: The set of all processes that are in main memory and are
waiting for CPU time is kept in the ready queue.
Waiting (Device) Queues: The set of processes waiting for allocation of
certain I/O devices is kept in the waiting (device) queue.
Context Switching
Switching of the CPU from one process to another.
The execution of the process that is present in the running state is suspended by the
kernel and another process that is present in the ready queue is executed by the CPU.
It is one of the essential features of the multitasking operating system. The processes are
switched so fast that it gives an illusion to the user that all the processes are being
executed at the same time.
When an interrupt occurs, the system needs to save the current ‘context’ of the process
running on the CPU so that it can restore that context later.
The context is represented in the PCB of the process and includes
The value of the CPU registers
The process state
Memory-management information. Generically, T
The current state of the process, be it in kernel or user mode