200 likes | 305 Views
CS134: October 15, 2001. Process control and scheduling Process Control Block Resource Control Block Scheduling. Context. The kernel is a set of primitive operations and processes A “primitive operation” is a subroutine that is part of the calling process (often a critical section)
E N D
CS134: October 15, 2001 • Process control and scheduling • Process Control Block • Resource Control Block • Scheduling Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Context • The kernel is a set of primitive operations and processes • A “primitive operation” is a subroutine that is part of the calling process (often a critical section) • A process requesting a service from another sends a request message, and (usually) blocks until the service is performed • The service process (usually) blocks until it receives a request Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Kernel operation classes • Primitives for process creation, destruction, and basic interprocess communication • Primitives for allocating and releasing resources (such as memory, storage, IO devices, files...) • Input and output primitives • Operations to handle interrupts Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Process Creation Hierarchy Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Process state diagram Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Process Control Block Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Identification • Identification: each process is uniquely identified by a pointer to its process control block; it also has some other description (a string or number) that identifies it. The kernel provides a function ID -> *PCB Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
State Vector • State: information required by the processor to run the process. Modified by execution of the process, or other processes that share the state vector • CPU state: process capabilities and protection info (and PC and register contents when blocked). Usually defined by processor architecture • Processor: set to processor number when executing (undefined otherwise) • Memory: storage map (page or segment table with VM), shared or owned • Resources: allocated resources (resource class + unit description) Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Status Information • Status: • running: the process in running on the processor Processor • ready: the process is ready to run, waiting for a processor • blocked: the process can’t proceed until it receives a resource or a message • In addition, the status may allow a suspended state (^Z) • The status data is a pointer to the a job queue (ready or waiting) Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Other • Process hierarchy • Parent pointer (the root process will be null) • Linked list of children • Other • Priority • Policy info • ... Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Linux PCB (struct task_struct) Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Linux PCB Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Linux ID Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Linux State Vector Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Linux Other Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Resource Descriptors • Resources include hardware components, as well as software components that satisfy the definitions of resources: • An inventory: listing the number and id of available units • A waiting list of blocked process with unsatisfied requests for the resource • An allocator responsible for deciding which requests should be honored and when • Hardware resources: drives, I/O devices, ... • Software resources: message queues, buffers, IRQs, ... Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Resource descriptor Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Resource components • Inventory list avail: a list of units (hardware devices, buffers, etc) • Waiting process list waiters: linked list of waiting processes with details about the type of request and allocation (result) area • Allocator: matches available resources with requests of waiting processes Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
The processor resource • Processors are a special kind of resource: • Processes are not “blocked” when they are waiting for a processor; they are “ready” • Processes wait on a “ready list” RL: which is the Waiters for the processor resource • The ready-list is a priority queue Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014
Queues • A queue supports two operations • insert(q, p): adds process p to queue q • remove(q): deletes and returns an element of the q • FIFO: insertion is always onto the end of the queue, removal is from the front Computing Systems http://www.cs.caltech.edu/cs134/cs134a August 23, 2014