【文章內(nèi)容簡介】
rocess – spends more time doing putations。 few very long CPU bursts. 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. ? Contextswitch time is overhead。 the system does no useful work while switching. ? Time dependent on hardware support. Process Creation ? Parent process creates children processes, which, in turn create other processes, forming a tree of processes. ? Resource sharing ? Parent and children share all resources. ? Children share subset of parent’s resources. ? Parent and child share no resources. ? Execution ? Parent and children execute concurrently. ? Parent waits until children terminate. Process Creation (Cont.) ? Address space ? Child duplicate of parent. ? Child has a program loaded into it. ? UNIX examples ? fork system call creates new process ? execlp system call used after a fork to replace the process’ memory space with a new program. A Tree of Processes On A Typical UNIX System Process Termination ? Process executes last statement and asks the operating system to delete it (exit). ? Process’ resources are deallocated by operating system. ? Output data from child to parent (via wait). ? Parent may terminate execution of children processes ? Child has exceeded超過 allocated resources. ? Task assigned to child is no longer required. ? Parent is exiting. ? Operating system does not allow child to continue if its parent terminates. ? Cascading termination. 級聯(lián)終止 Cooperating Processes ? Independent process cannot affect or be affected by the execution of another process. ? Cooperating process can affect or be affected by the execution of another process ? Advantages of process cooperation ? Information sharing ? Computation speedup ? Modularity ? Convenience ProducerConsumer Problem ? Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process. ? unboundedbuffer places no practical limit on the size of the buffer. 無界緩沖沒有對緩沖區(qū)大小的限制 ? boundedbuffer assumes that there is a fixed buffer size. 有界緩沖對緩沖區(qū)大小作了限定 BoundedBuffer