Process LIfecycle and PCB
Process LIfecycle and PCB
By
Hamna Khalid
1
Process Concept & Scheduling
and
Process Control Block(PCB)
2
Process
• A process is an instance of a program in
execution.
• Batch systems work in terms of "jobs". Many
modern process concepts are still expressed in
terms of jobs, ( e.g. job scheduling ), and the
two terms are often used interchangeably.
3
Process
• A process is a program in execution which then
forms the basis of all computation.
• The process is not as same as program code but
a lot more than it.
• A process is an 'active' entity as opposed to the
program which is considered to be a 'passive'
entity.
• Attributes held by the process include
hardware state, memory, CPU, etc.
4
Process in Memory
Process memory is divided into four sections for efficient
working :
• The 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 of 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, free, etc.
• The Stack is used for local variables. Space on the stack is
reserved for local variables when they are declared.
5
Process in Memory
6
Process Scheduling
• When there are two or more runnable
processes then it is decided by the Operating
system which one to run first then it is
referred to as Process Scheduling.
• A scheduler is used to make decisions by using
some scheduling algorithm.
7
3 Types of Scheduling Queues
• Job queue − This queue keeps all the
processes in the system.
• Ready queue − This queue keeps a set of all
processes residing in main memory, ready and
waiting to execute. ...
• Device queues − The processes which are
blocked due to unavailability of an I/O device
constitute this queue.
8
Process States
9
Process Lifecycle
10
Categories of Process Scheduling
Scheduling falls into one of two categories:
11
Job Scheduling vs. CPU Scheduling
12
Types of Process Schedulers
13
Types of Process Schedulers
14
Types of 3. Medium-Term Scheduler
It is responsible for suspending and resuming the process. It
Process mainly does swapping (moving processes from main memory
Schedulers to disk and vice versa). Swapping may be necessary to
improve the process mix or because a change in memory
requirements has overcommitted available memory,
requiring memory to be freed up. It is helpful in maintaining a
perfect balance between the I/O bound and the CPU bound.
15
Process Control Block
• There is a Process Control Block for each
process, enclosing all the information about
the process. It is also known as the task
control block.
16
Process Control Block
17
Process Control Block
It is a data structure, which contains the following:
• Process State: It can be running, waiting, etc.
• Process ID and the parent process ID.
• CPU registers and Program Counter. Program
Counter holds the address of the next
instruction to be executed for that process.
• CPU Scheduling information: Such as priority
information and pointers to scheduling queues.
18
Process Control Block
• Memory Management information: For
example, page tables or segment tables.
• Accounting information: The User and kernel
CPU time consumed, account numbers, limits,
etc.
• I/O Status information: Devices allocated,
open file tables, etc.
19
Process vs. Program
Process Program
A Program is basically a
The process is basically collection of
an instance of the instructions that mainly
computer program that performs a specific task
is being executed. when executed by the
computer.
20
Process vs. Program
A process has A Program has
a shorter lifetime. a longer lifetime.
A Process requires A Program is stored
resources such as by hard-disk and
memory, CPU, Input- does not require any
Output devices. resources.
21
Process vs. Program
A process has a
A Program has static
dynamic instance of
code and static data.
code and data
Basically, a process is On the other hand, the
the running instance of program is
the code. the executable code.
22