PROCESS and STATES (Autosaved) (Autosaved)
PROCESS and STATES (Autosaved) (Autosaved)
Process Concept
• Process – a program in execution;
• A process includes:
– program counter
– stack
– data section
Process in Memory
Process State
• As a process executes, it changes state
– new: The process is being created
– running: Instructions are being executed
– waiting: The process is waiting for some event to
occur
– ready: The process is waiting to be assigned to a
processor
– terminated: The process has finished execution
Diagram of Process State
Process Control Block (PCB)
Each process is represented in operating system by process control block
Information associated with each process
• Process state
• Program counter: Next Instruction to be executed
• CPU registers
• CPU scheduling information: includes process priority, and any other
scheduling parameters.
• Memory-management information: : includes information of the base and
limit registers, the page tables etc.
• Accounting information: includes amount of CPU, time limits etc.
• I/O status information: includes list of I/O devices allocated to the process, a
list of open files and so on.
Process Control Block (PCB)
Context Switch
• When CPU switches to another process, the
system must save the state of the old process and
load the saved state for the new process via a
context switch
• Context of a process represented in the PCB
• Context-switch time is overhead; the system does
no useful work while switching
• Time dependent on hardware support
CPU Switch From Process to
Process
Process Scheduling
• Maximize CPU use, quickly switch processes onto CPU for time
sharing
• Process scheduler selects among available processes for next
execution on CPU
• Maintains scheduling queues of processes
– 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 an I/O device
– Processes migrate among the various queues
Representation of Process Scheduling