Tuesday, August 11, 2009

PCB: process control block

1
Processes – Part II
Peiyi Tang University of Arkansas at Little Rock
2
Contents
1 2 3 4 5
Context of Execution of a Program 3 Process Control Block 5 Process State and its Transition 7 Process Scheduling 10 Context Switch 15
Contents 3
1
Context of Execution of a Program
address space (text, data, stack and heap)
program counter (PC): register for the address of next instruction
stack pointer (SP): register for the address of the top of stack
frame pointer (FP): register for the address of current stack frame
registers (user and system registers) I/O resources (open files, open network sockets, etc)
• •
• •
• •
1 Context of Execution of a Program 4
A process is a program in execution. Therefore, a process should be characterized by its
• address space (text, data, stack and heap) • program counter (PC): register for the address of next
instruction
• stack pointer (SP): register for the address of the top of stack
• frame pointer (FP): register for the address of current stack frame
• registers (user and system registers) • I/O resources (open files, open network sockets, etc)
1 Context of Execution of a Program 5
2 Process Control Block
Process control block is the data structure to store all information to resume the process after it is suspended or blocked.
• process state • program counter (PC) and frame pointer (FP) • registers • address space • open I/O resources
2 Process Control Block 6
2 Process Control Block 7
3 Process State and its Transition
Each process can be in one of the five states • new
• ready • running • blocked (wait) • exit (terminated)
3 Process State and its Transition 8
State Transitions and Their causes
• nothing to new: process creation
• new to ready: dispatch by job scheduler or swap in by middle-term scheduler
• ready to run: dispatch by the CPU scheduler • run to ready: time-out interrupt for time-sharing
multiprogramming or others reasons
• run to blocked: requests for services of the operating system which take time to complete
• blocked to ready: completions of requested services
3 Process State and its Transition 9
State Transition Diagram
3 Process State and its Transition 10
4 Process Scheduling
Queuing Model: where do the ready or wait processes stay?
• Address spaces stay in memory, but PCB information stays in queues.
• ready queue: the queue to store the PCB of the ready processes
• wait queues: the queues to store the PCB of the waiting processes
• single- or multiple-queue model for the waiting processes
4 Process Scheduling 11
Ready queue and various I/O queues
4 Process Scheduling 12
Schedulers
• CPU scheduler (short-term scheduler): the function to select the process in the ready queue to run it on CPU.
• Job scheduler (long-term scheduler): the function to select the process in the new state to put it into the ready queue.
• Medium-term scheduler: the function to select the partially-executed swapped-out process to the ready queue.
4 Process Scheduling 13
Queueing-diagram representation of process scheduling.
4 Process Scheduling 14
Addition of medium-term scheduler to the queueing diagram.
4 Process Scheduling 15
5 Context Switch
A context switch from process P1 to process P2 is required, when • P1 is changed from running to blocked or ready and • P2 is changed from ready to running
The context switch from P1 to P2 involves: • save the context of P1 in its PCB and put it in an appropriate
queue
• load the context of P2 from its PCB
• resume the execution of P2 from the address where it was stopped
5 Context Switch 16
CPU switches from process to process.

No comments:

Post a Comment