0% found this document useful (0 votes)
39 views16 pages

What Is A Program and Process?

This document discusses the differences between programs and processes, types of processes, process states, process control blocks, context switching, and process scheduling queues. A program is a passive set of instructions, while a process is an actively executing program with a program counter specifying the next instruction. Processes can be CPU-bound or I/O-bound. Process states include new, ready, running, waiting, and terminated. A process control block stores process information for execution. Context switching saves and loads process states when switching between CPU processes. Scheduling involves long, short, and medium term schedulers managing queues like job, ready, and device queues.

Uploaded by

hamna noor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views16 pages

What Is A Program and Process?

This document discusses the differences between programs and processes, types of processes, process states, process control blocks, context switching, and process scheduling queues. A program is a passive set of instructions, while a process is an actively executing program with a program counter specifying the next instruction. Processes can be CPU-bound or I/O-bound. Process states include new, ready, running, waiting, and terminated. A process control block stores process information for execution. Context switching saves and loads process states when switching between CPU processes. Scheduling involves long, short, and medium term schedulers managing queues like job, ready, and device queues.

Uploaded by

hamna noor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

What is a program and process?

 Program – a passive entity and composed of set


of instructions.

 Process – an active entity and it is a program in


execution with PC specifying the address of next
instruction to be executed.
CPU and I/O Bound Processes

Processes can be:


 I/O-bound process – spends more time doing I/O
than computations, many short CPU bursts.

I/O Burst CPU Burst I/O Burst CPU Burst

 CPU-bound process – spends more time doing


computations; few very long CPU bursts.

CPU Burst I/O CPU Burst I/O


Process States
As a process executes, it can be in one of
following states
 new: The process is being created.
 ready: The process is waiting to be assigned to

a processor.
 running: Instructions are being executed.
 waiting: The process is waiting for some event

to occur.
 terminated: The process has finished execution.
Process States
Process Control Block
(PCB)
PCB is a OS data structure, allocated to each process when it
is created. The OS keeps all the data it needs about the
process for its execution in PCB.
 Process state

 Program counter

 CPU registers

 CPU scheduling information

 Memory-management information

 Accounting information

 I/O status information

 Per process file table

 Process ID (PID)

 Parent PID, etc.


Process Control Block (PCB)
CPU Switch From Process
to Process
Context Switch
 When CPU switches to another process, the
system must save the state (context) of the
‘current’ (old) process and load the saved state for
the new process.
 Context-switch time is overhead; the system does
no useful work while switching.
 Time dependent on hardware support; typically in
microseconds
Process Scheduling Queues

 Job queue – set of all processes in the system.

 Ready queue – set of all processes residing in


main memory, ready and waiting to execute.

 Device queues – set of processes waiting for I/O


devices.

 Process migration between the various queues.


Queues in the OS
Queues in a Computer System
Schedulers
 Long term scheduler
 Short term scheduler
 Medium term scheduler
Long Term Scheduler
 Long-term scheduler (or job scheduler) – selects
processes from the job pool to be brought into the
ready queue.
 Long-term scheduler is invoked very infrequently
(seconds, minutes)  (may be slow).
 The long-term scheduler controls the degree of
multiprogramming.
 More processes, smaller percentage of time each
process is executed
Short Term Scheduler
 Short-term scheduler (or CPU scheduler) – selects
which process should be executed next and
allocates it the CPU through the dispatcher.
 Short-term scheduler is invoked very frequently
(milliseconds)  (must be fast).
 Invoked when following events occur
• CPU slice of the current process finishes
• Current process needs to wait for an event
• Clock interrupt
• I/O interrupt
• System call
Medium Term Scheduler
 Also known as swapper
 Selects an in-memory process and swaps it out to
the disk temporarily
 Swapping decision is based on several factors
• Arrival of a higher priority process but no
memory available
• Poor mix of jobs
• Memory request of a process cannot be met
Addition of Medium Term
Scheduling

You might also like