5. 3.1.1 Process Concepts
What is a program ??
Inactive@passive entity, such as a file stored on a
disk.
To an operating system, a program/job/ task is a
unit of work that has been submitted by user.
“Job” is usually associated with batch systems.
“Task” is usually associated with multitasking
systems.
What is a process ??
A process is a program in execution.
Active entity, which requires a set of resources, including
a processor and special registers to perform its function.
6. 3.1.1 Process Concepts
A process includes :-
Stack (contain temporary data)
Data section (contain global variables)
Heap (memory that is automatically
allocated during process runtime)
2 types of process :-
O/S process = executes system codes
User process = executes user codes.
7. 3.1.1 Process Concepts
Each process is represented in the OS by a
process control block (PCB) or task control
block.
Each PCB is unique, there are no two PCB’s
alike
8. 3.1.1 Process Concepts
Process Control Block (PCB)
Identify the current state new, ready,
running, waiting, terminated
Accounting information includes the
amount of CPU and real time used,
time limits, process numbers and
etc.
Accumulators, index, stack pointers,
state info when interrupt occurs.
I/O status information list of I/O
devices allocate for this process. List
of open files.
CPU scheduling information includes
a process priority, pointers to
scheduling queues or other
scheduling parameters
Counter indicated the address of
next instructions to be executed by
this process
Memory management information,
value of base & limit registers, page
tables, segment tables used by O/S
9. 3.1.1 Process Concepts
Process State
As a process executes, it changes state.
The state of a process is defined in part by the
current activity of that process.
Only one process can be running on any
processor at any instant.
However, many processes may be ready and
waiting for their turn to be processed.
10. 3.1.1 Process Concepts
Process State includes:
New : The process is being
created.
Running : Instructions are being
executed.
Waiting : The process is waiting for
some event to occur (such as an I/O
completing or reception of a signal)
Ready : The process is waiting to
be assigned to a processor
Terminated : The process has finished
execution
11. 3.1.1 Process Concepts
Hold(New)
Ready Running
Waiting
I/O or event
completion
Scheduler dispatch
I/O or event
wait
Admitted
Interrupt Exit
Finished
Handled by Process Scheduler
Handled by Job Scheduler
Job pool
Diagram of Process State
12. 3.1.1 Process Concepts
In a processing cycle, a process might have
to wait for computer resources, as it waits,
the process will be placed in a queue
Job queue - set of all processes in the
system, that are waiting to be moved
into memory.
Ready queue - set of all processes
residing in main memory, ready and
waiting to be executed by CPU.
Device @ I/O queue - set of processes
waiting for an I/O device
14. 3.1.1 Process Concepts
O/S control the selection of the process
from one queue to another.
The selection of the process is carried out
by a scheduler
1. LongTerm Scheduler (Job Scheduler)
2. Short Term Scheduler (Process @ CPU
Scheduler)
3. MediumTerm Scheduler
15. 3.1.1 Process Concepts
LongTerm Scheduler
Also known as Job Scheduler.
Selects processes from the job queue and loads
them into memory for execution.
Long-term scheduler is invoked very
infrequently and slow.
The long-term scheduler controls the degree of
multiprogramming and a good combination of
I/O bound and CPU bound processes.
16. 3.1.1 Process Concepts
ShortTerm Scheduler
Also known as Process or CPU Scheduler.
Select from among the processes that are
ready to execute and allocates the CPU to one
of them.
Short-term scheduler is invoked very
frequently and very fast.
17. 3.1.1 Process Concepts
MediumTerm Scheduler
The process will be swapped out from memory
and swapped back in later for continuation.
This swapping scheme is to reduce the degree
of multiprogramming and balance the process
mixture.
18. 3.1.1 Process Concepts
Context Switch
Happens when switching the CPU to another
process.
Saving the state of the old process and loading
the saved state for new process.
19. 3.1.1 Process Concepts
Process Manager performs job scheduling,
process scheduling and interrupt
management.
In single-tasking, processor is busy only when
user is executing a job—at all other times it is
idle.
Processor management is simple.
In multiprogramming environment, processor
must be allocated to each job in a fair and
efficient manner.
Requires scheduling policy and a scheduling
algorithm. Eg. FCFS, SJF, SRTF, RR etc.
20. 3.1.2 SingleTasking
Only one program executed at a time
Begins running a new program on a
computer system as soon as the current
program is completed.
Example: Palm OS for Palm handheld
computers
Single tasking is divided by 2 types of
processing:
1) Sequential Processing
2) Batch Processing
Memory layout of
early computer
systems
21. 3.1.2 SingleTasking
Sequential Processing
New programs or commands cannot be
started until the preceding program or
command has completed.
Example: when you enter commands line
by line.
Will complete executing each command
before going on to the next
22. 3.1.2 SingleTasking
Batch Processing
Jobs or several user programs are grouped into
a batch and processed one after another in a
continuous stream.
Not interactive so user cannot interact with
program while the program is running.
Example: The customer does not receive a bill
for each separate credit card purchase but one
monthly bill for all of that month's purchases.
24. 3.1.3 Multi-tasking
Multi-tasking OS provides the ability to run more
than one program at once.
Multi-tasking is divided by 2 types of
processing:
1) Multiprogramming
2) Time Sharing Systems
26. 3.1.3 Multi-tasking
Multiprogramming
Batched and non-interactive
Multiprogramming increases CPU utilization by
organizing jobs so that the CPU always has one
to execute
The operating system keeps several jobs in
memory simultaneously
It picks and begins to execute one of the jobs
in memory
27. 3.1.3 Multi-tasking
Multiprogramming
Eventually, the job may have to wait for some
task to complete
In a multiprogrammed system, the OS switches
to another job and executes it
The first job finishes waiting and gets the CPU
back
As long as at least one job needs to execute –
the CPU is never idle
29. 3.1.3 Multi-tasking
Time Sharing Systems
Time sharing is a logical extension of
multiprogramming
In time sharing systems, the CPU executes
multiple jobs by switching among them, but the
switches occur so frequently that the users can
interact with each program while it is running
It requires an interactive computer system
providing direct communication between user
and the system