800 likes | 1.78k Views
PROCESS Control BLOCK & PROCESS SCHEDULING. Dhanjit Das 11CS10012 Operating Systems – Scribe submission | 22/1/14. Process Control Block (PCB). Also called: Task Controlling Block Task Struct Switchframe
E N D
PROCESS Control BLOCK &PROCESS SCHEDULING Dhanjit Das 11CS10012 Operating Systems – Scribe submission | 22/1/14
Process Control Block (PCB) • Also called: • Task Controlling Block • Task Struct • Switchframe • is a data structure in the operating system kernel containing the information needed to manage a particular process. • The PCB is "the manifestation of a process in an operating system”
Role of PCB • Central in process management: they are accessed and/or modified by most OS utilities, including those involved with scheduling, memory and I/O resource access and performance monitoring. • The set of the PCBs defines the current state of the operating system. • Data structuring for processes is often done in terms of PCBs. For example, pointers to other PCBs inside a PCB allow the creation of those queues of processes in various scheduling states ("ready", "blocked", etc.) that we previously mentioned.
PCB Structure Information associated with each process • Process state • Program counter • CPU registers • Accumulator, Index reg., stack pointer, general Purpose reg., Program Status Word (PSW) • CPU scheduling information • Priority info, pointer to scheduling queue • Memory-management information • Memory information of a process • Base register, Limit register, page table, segment table • Accounting information • CPU usage time, Process ID, Time slice • I/O status information • List of open files=> file descriptors • Allocated devices
Process Representation in Linux • Process is represented by a task_struct data structure
Its fields can be divided into a number of functional areas: • State • Running: either running or is ready to run • Waiting: waiting for an event or for a resource • Stopped: stopped, usually by receiving a signal • Zombie: halted process which, still has a task_struct • Scheduling Information • Identifiers: each process has process identifier • Inter-Process Communication • classic Unix IPC mechanisms of signals, pipes and semaphore
Links: • Times and Timers • File system: keep track of files opened by process • Virtual memory: must track how that virtual memory is mapped
Context Switch • Procedure of storing the state of an active process for the CPU when it has to start executing a new one.
Context switch is essential feature of a multitaskingoperating system. • usually computationally intensive • Time dependent on hardware support • Some hardware provides multiple sets of registers per CPU -> multiple contexts loaded at once
Process Scheduling • requirement for most modern systems to perform: • multitasking(executing more than one process at a time) • multiplexing(transmit multiple data streams simultaneously across a single physical channel).
Performance Metrics • Throughput: The total number of processes that complete their execution per time unit. • Latency: • Turnaround time: total time between submission of a process and its completion. • Response Time: amount of time it takes from when a request was submitted until the first response is produced. • Fairness: Equal CPU time to each process (or more generally appropriate times according to each process' priority and workload). • Waiting Time: The time the process remains in the ready queue.
Queing • A new process is initially put in the ready queue. It waits there until it is selected for execution, or is dispatched. Once the process is allocated the CPU and is executing, one of several events could occur: • The process could issue an I/O request and then be placed in an I/O queue. • The process could create a new sub-process and wait for the sub-process's termination. • The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue. • A process continues this cycle until it terminates, at which time it is removed from all queues and has its PCB and resources de-allocated.
Types of Schedulers • Long Term Scheduler • It is also called job scheduler. • determines which programs are admitted to the system for processing. • selects processes from the queue and loads them into memory for execution. • provide a balanced mix of jobs, such as I/O bound and processor bound. • Short Term Scheduler • also called CPU scheduler. • change of ready state to running state of the process. • also known as dispatcher, execute most frequently and makes the fine grained decision of which process to execute next. • faster than long term scheduler.
Dispatcher • gives control of the CPU to the process selected by the short-term scheduler. • This function involves the following: • Switching context • Switching to user mode • Jumping to the proper location in the user program to restart that program. • Dispatcher Latency: amount of time it takes for a system to respond to a request for a process to begin operation. • With a scheduler written specifically to honor application priorities, real-time applications can be developed with a bounded dispatch latency.