進程管理英文PPT課件_第1頁
進程管理英文PPT課件_第2頁
進程管理英文PPT課件_第3頁
進程管理英文PPT課件_第4頁
進程管理英文PPT課件_第5頁
已閱讀5頁,還剩33頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks Textbook uses the terms job and process almost interchangeably. Process a program in execution A process includes: program counter stack data section第1頁/共38頁Process Concep

2、t 國內(nèi)學(xué)術(shù)界較為一致的定義: 進程是一個具有一定獨立功能的程序,關(guān)于某個數(shù)據(jù)集合的一次可以并發(fā)執(zhí)行的運行活動。 From Wikipedia In computing, a process is an instance of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs concurrently.第2頁/共38頁Process Concept A single computer p

3、rocessor executes one or more instructions at a time (per clock cycle), one after the other. To allow users to run several programs at once, single-processor computer systems can perform multiprogramming and time-sharing. Using more than one physical processor on a computer, permits true simultaneou

4、s execution of more than one stream of instructions from different processes. Concurrency is the term generally used to refer to several independent processes sharing a single processorSimultaneously (or parallel) is used to refer to several processes, each with their own processor.第3頁/共38頁Process v

5、s. ProgramDynamic/static process is a program in execution, so it is dynamic, program is a passive collection of instuctions, so it is a static entity.Lify cycle process has a life cycle. It is an active entity in the sense that it can be created, executed, and terminated during its lifetime. Progra

6、m can exist forever.Structure process = program + data + PCB Each process is represented in the OS by a process control block (PCB), it contains all information associated with a specific process.第4頁/共38頁Process vs. ProgramNo one-to-one mapping between processes and programs can have mulitple proces

7、ses of the same program one process can invoke multiple programsProcess is the basic unit of being scheduled and resource allocation from the viewpoint of OS, while program can not be run without process creation.Process can be executed concurrently or simultaneously.第5頁/共38頁Process State As a proce

8、ss executes, it changes state new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur. ready: The process is waiting to be assigned to a processor. terminated: The process has finished execution.第6頁/共38頁Diagram of Process S

9、tatenewreadyrunningwaiting/blockedterminatedadmittedI/O or event completionscheduler dispatchI/O or event waitinterruptexit第7頁/共38頁Process Control Block (PCB)Information associated with each process: Process state Program counter CPU registers CPU scheduling information Memory-management information

10、 Accounting information I/O status information第8頁/共38頁Process Control Block (PCB)第9頁/共38頁CPU Switch From Process to Process第10頁/共38頁Chapter 4: Processes Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication第11頁/共38頁Process SchedulingProcess Schedu

11、ling Queues Job queue set of all processes in the system. Ready queue set of all processes residing in main memory,ready and waiting to execute. Device queues set of processes waiting for an I/O device.Process migration between the various queues. 第12頁/共38頁Ready Queue And Various I/O Device Queues第1

12、3頁/共38頁Representation of Process Scheduling第14頁/共38頁Schedulers Long-term scheduler (or job scheduler) selects which processes should be brought into the ready queue. 長程調(diào)度(或作業(yè)調(diào)度) Short-term scheduler (or CPU scheduler) selects which process should be executed next and allocates CPU. 短程調(diào)度(或CPU調(diào)度)第15頁/

13、共38頁Addition of Medium Term Scheduling第16頁/共38頁Schedulers (Cont.) Short-term scheduler is invoked very frequently (milliseconds) (must be fast). 調(diào)用頻率高 Long-term scheduler is invoked very infrequently (seconds, minutes) (may be slow). 調(diào)用頻率不高 The long-term scheduler controls the degree of multiprogram

14、ming. 長程調(diào)度控制了多道程序的“道數(shù)” Processes can be described as either: I/O-bound process spends more time doing I/O than computations, many short CPU bursts. CPU-bound process spends more time doing computations; few very long CPU bursts.第17頁/共38頁Context Switch上下文切換 When CPU switches to another process, the s

15、ystem must save the state of the old process and load the saved state for the new process. Context-switch time is overhead; the system does no useful work while switching. Time dependent on hardware support.第18頁/共38頁Process Creation Parent process creates children processes, which, in turn create ot

16、her processes, forming a tree of processes. Resource sharing Parent and children share all resources. Children share subset of parents resources. Parent and child share no resources. Execution Parent and children execute concurrently. Parent waits until children terminate.第19頁/共38頁Process Creation (

17、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. 第20頁/共38頁A Tree of Processes On A Typical UNIX System第21頁/共38頁Process Te

18、rmination 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 assigne

19、d 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)終止第22頁/共38頁Cooperating ProcessesIndependent process cannot affect or be affected by the execution of another process. Cooperating process can affe

20、ct or be affected by the execution of another process Advantages of process cooperation Information sharing Computation speed-up Modularity Convenience第23頁/共38頁Producer-Consumer Problem Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process.

21、unbounded-buffer places no practical limit on the size of the buffer. 無界緩沖沒有對緩沖區(qū)大小的限制bounded-buffer assumes that there is a fixed buffer size. 有界緩沖對緩沖區(qū)大小作了限定第24頁/共38頁Bounded-Buffer Shared-Memory Solution Shared datavar n;type item = ;var buffer. array 0.n1 of item;in, out: 0.n1; Producer process rep

22、eatproduce an item in nextpwhile in+1 mod n = out do no-op;buffer in :=nextp;in :=in+1 mod n;until false;第25頁/共38頁Bounded-Buffer (Cont.) Consumer process repeatwhile in = out do no-op;nextc := buffer out;out := out+1 mod n;consume the item in nextc until false; Solution is correct, but can only fill

23、 up n1 buffer.第26頁/共38頁Threads A thread (or lightweight process) is a basic unit of CPU utilization; it consists of: program counter register set stack space A thread shares with its peer threads its: code section data section operating-system resourcescollectively know as a task. 整體作為一個任務(wù)第27頁/共38頁T

24、hreads (Cont.) In a multiple threaded task, while one server thread is blocked and waiting, a second thread in the same task can run. Cooperation of multiple threads in same job confers higher throughput and improved performance. Applications that require sharing a common buffer (i.e., producer-cons

25、umer) benefit from thread utilization. Threads provide a mechanism that allows sequential processes to make blocking system calls while also achieving parallelism. Kernel-supported threads (Mach and OS/2). User-level threads; supported above the kernel, via a set of library calls at the user level.

26、Hybrid approach implements both user-level and kernel-supported threads (Solaris 2). 混合處理實現(xiàn)用戶級和內(nèi)核支持線程第28頁/共38頁Interprocess Communication-IPC Mechanism for processes to communicate and to synchronize their actions. Message system processes communicate with each other without resorting to shared varia

27、bles. IPC facility provides two operations send(message) message size fixed or variable receive(message) If P and Q wish to communicate, they need to : establish a communication link between them exchange messages via send/receive Implementation of communication link physical (e.g., shared memory, h

28、ardware bus) logical (e.g., logical properties)第29頁/共38頁Implementation Questions How are links established? Can a link be associated with more than two processes? How many links can there be between every pair of communicating processes? What is the capacity of a link? ? Is the size of a message tha

29、t the link can accommodate fixed or variable? Is a link unidirectional or bi-directional? 第30頁/共38頁Direct Communication Processes must name each other explicitly顯式: send (P, message) send a message to process P receive(Q, message) receive a message from process Q Properties of communication link Lin

30、ks are established automatically. A link is associated with exactly one pair of communicating processes. Between each pair there exists exactly one link. The link may be unidirectional, but is usually bi-directional.第31頁/共38頁Indirect Communication Messages are directed and received from mailboxes. E

31、ach mailbox has a unique id. Processes can communicate only if they share a mailbox. Properties of communication link Link established only if processes share a common mailbox A link may be associated with many processes. Each pair of processes may share several communication links. Link may be unidirectional.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論