Monday, September 6, 1993 Today: Sequential processes terminology and introduction to implementation ------------------------------------------------------------------------ First some related terminology: Multiprogramming: intuitively, more than one process (activity) can be ready to run. CPU switches among them Multiprocessor systems: multiple CPUs. Generally MIMD. Symmetric: each processor runs identical copy of OS. Copies communicate as necessary tightly coupled: share main memory loosely coupled: connected via communication links assymmetric: each processor has specific task (e.g., master/slave; channels, etc.) Multitasking (timesharing): multiprogramming with fast switching so it appears to user that all programs are running simultaneously. Opposite terms: multiprogramming and uniprogramming multiprocessor and uniprocessor Orthogonal terms: multiprogramming and multiprocessor ------------------------------------------------------------------------ Process: First cut at definition: sequential process (or process) is a program in execution. Program---passive entity (static---code). Process---active entity (dynamic) but note that "sequential process" does not exactly correspond to program in execution: one program can spawn multiple processes (fork); multiple processes can implement a single program, either in sequence (e.g., C compiler) or simultaneously as above. Sequential process characteristics: - sequential: at any point in time *at most* one instruction executed on behalf of process - formed from a running piece of code plus environment [all the things it affects and all the things affected by it] - from point of view of CPU, environment encoded in program counter (next instruction to execute); process stack (return address, subroutine paramenters, local data, temporary variables); global data section (global variables) execution stream: sequence of instructions performed by a process+environment Aside: notion of process tied in strongly with decomposition Aside: object and process can be related (e.g., ADT). Process as logical construct. ------------------------------------------------------------------------ Process state (finite state diagram)/System's view of a process States: Ready: The process is waiting to be assigned to a processor Running: Instructions are being executed Blocked (waiting): The process is waiting for some event to occur (e.g., I/O completion) State transitions (operation: old state -> new state) new: -> ready dispatch:ready -> running invoked by OS timeslice over: running -> ready invoked by OS exit: running -> block: running-> blocked invoked by process wakeup: blocked -> ready invoked by OS --- In uniprocessor at most *one* process can be running at any instant Many can be ready or blocked Dispatcher (or scheduler) figures out which process is to be moved from ready to running states Timer causes process to move from running to ready states when time slice (quantum) expires Process requests block by for example invoking i/o system call wakeup occurs when request satisfied (perhaps by interrupt handler) ------------------------------------------------------------------------ Process control block (PCB) also called process descriptor - Represents process to operating system - Located at fixed location (but perhaps in virtual memory) How many processes can be active at a given instant? Number of PCBs (SYSGEN parameter) - Stores that information that varies from process to process - OS designer specifies fields as appropriate (keeping memory use in mind). For example: - unique identifier for process - current state of process (new, ready, running, waiting, halted) - pointer to process' parent - pointer(s) to children processes if any - space to save/restore needed values - program counter - CPU registers - current addressing mode (user/supervisor) - CPU scheduling information (priority, scheduler data structures) - memory management information (e.g., limit register, page tables [for location of process' memory]) - pointers to allocated resources and i/o status information (e.g., devices, list of open files, etc.) - accounting information (CPU time used, wall clock time used, time limits, account numbers, etc.) - Additional information as required by configuration can also be included in design, e.g., identity of processor process is running on if a multiprocessor system.