收藏 分销(赏)

进程管理英文.pptx

上传人:天**** 文档编号:4173435 上传时间:2024-08-11 格式:PPTX 页数:38 大小:525.26KB
下载 相关 举报
进程管理英文.pptx_第1页
第1页 / 共38页
进程管理英文.pptx_第2页
第2页 / 共38页
进程管理英文.pptx_第3页
第3页 / 共38页
进程管理英文.pptx_第4页
第4页 / 共38页
进程管理英文.pptx_第5页
第5页 / 共38页
点击查看更多>>
资源描述

1、Chapter 4:ProcessesnProcess ConceptnProcess SchedulingnOperation on ProcessesnCooperating ProcessesnInterprocess CommunicationProcess ConceptnAn operating system executes a variety of programs:nBatch system jobsnTime-shared systems user programs or tasksnTextbook uses the terms job and process almos

2、t interchangeably.nProcess a program in executionnA process includes:nprogram counternstack ndata sectionProcess Conceptn国内学术界较为一致的定义:进程是一个具有一定独立功能的程序,关于某个数据集合的一次可以并发执行的运行活动。nFrom Wikipedia In computing,a process is an instance of a computer program that is being sequentially executed by a computer

3、system that has the ability to run several computer programs concurrently.Process ConceptnA single computer processor executes one or more instructions at a time(per clock cycle),one after the other.nTo allow users to run several programs at once,single-processor computer systems can perform multipr

4、ogramming and time-sharing.nUsing more than one physical processor on a computer,permits true simultaneous execution of more than one stream of instructions from different processes.nConcurrency is the term generally used to refer to several independent processes sharing a single processornSimultane

5、ously(or parallel)is used to refer to several processes,each with their own processor.Process vs.ProgramnDynamic/staticnprocess is a program in execution,so it is dynamic,nprogram is a passive collection of instuctions,so it is a static entity.nLify cyclenprocess has a life cycle.It is an active ent

6、ity in the sense that it can be created,executed,and terminated during its lifetime.nProgram can exist forever.nStructurenprocess=program+data+PCBnEach process is represented in the OS by a process control block(PCB),it contains all information associated with a specific process.Process vs.ProgramnN

7、o one-to-one mapping between processes and programsncan have mulitple processes of the same programnone process can invoke multiple programsnProcess is the basic unit of being scheduled and resource allocation from the viewpoint of OS,while program can not be run without process creation.nProcess ca

8、n be executed concurrently or simultaneously.Process StatenAs a process executes,it changes statennew:The process is being created.nrunning:Instructions are being executed.nwaiting:The process is waiting for some event to occur.nready:The process is waiting to be assigned to a processor.nterminated:

9、The process has finished execution.Diagram of Process Statenewreadyrunningwaiting/blockedterminatedadmittedI/O or event completionscheduler dispatchI/O or event waitinterruptexitProcess Control Block(PCB)Information associated with each process:nProcess state nProgram counternCPU registers nCPU sche

10、duling informationnMemory-management informationnAccounting informationnI/O status informationProcess Control Block(PCB)CPU Switch From Process to ProcessChapter 4:ProcessesnProcess ConceptnProcess SchedulingnOperation on ProcessesnCooperating ProcessesnInterprocess CommunicationProcess SchedulingPr

11、ocess Scheduling QueuesnJob queue set of all processes in the system.nReady queue set of all processes residing in main memory,ready and waiting to execute.nDevice queues set of processes waiting for an I/O device.Process migration between the various queues.Ready Queue And Various I/O Device Queues

12、Representation of Process SchedulingSchedulersnLong-term scheduler(or job scheduler)selects which processes should be brought into the ready queue.长程调度(或作业调度)长程调度(或作业调度)nShort-term scheduler(or CPU scheduler)selects which process should be executed next and allocates CPU.短程调度(或短程调度(或CPU调度)调度)Additio

13、n of Medium Term SchedulingSchedulers(Cont.)nShort-term scheduler is invoked very frequently (milliseconds)(must be fast).调用频率高调用频率高nLong-term scheduler is invoked very infrequently (seconds,minutes)(may be slow).调用频率不高调用频率不高nThe long-term scheduler controls the degree of multiprogramming.长程调度控制了多道程

14、序的长程调度控制了多道程序的“道数道数”nProcesses can be described as either:nI/O-bound process spends more time doing I/O than computations,many short CPU bursts.nCPU-bound process spends more time doing computations;few very long CPU bursts.Context Switch上下文切换上下文切换nWhen CPU switches to another process,the system mus

15、t save the state of the old process and load the saved state for the new process.nContext-switch time is overhead;the system does no useful work while switching.nTime dependent on hardware support.Process CreationnParent process creates children processes,which,in turn create other processes,forming

16、 a tree of processes.nResource sharingnParent and children share all resources.nChildren share subset of parents resources.nParent and child share no resources.nExecutionnParent and children execute concurrently.nParent waits until children terminate.Process Creation(Cont.)nAddress spacenChild dupli

17、cate of parent.nChild has a program loaded into it.nUNIX examplesnfork system call creates new processnexeclp system call used after a fork to replace the process memory space with a new program.A Tree of Processes On A Typical UNIX SystemProcess TerminationnProcess executes last statement and asks

18、the operating system to delete it(exit).nProcess resources are deallocated by operating system.nOutput data from child to parent(via wait).nParent may terminate execution of children processes nChild has exceeded超过超过 allocated resources.nTask assigned to child is no longer required.nParent is exitin

19、g.nOperating system does not allow child to continue if its parent terminates.nCascading termination.级联终止级联终止Cooperating ProcessesnIndependent process cannot affect or be affected by the execution of another process.nCooperating process can affect or be affected by the execution of another processnA

20、dvantages of process cooperationnInformation sharingnComputation speed-upnModularitynConvenienceProducer-Consumer ProblemnParadigm for cooperating processes,producer process produces information that is consumed by a consumer process.nunbounded-buffer places no practical limit on the size of the buf

21、fer.无界缓冲没有对缓冲区大小的限制无界缓冲没有对缓冲区大小的限制nbounded-buffer assumes that there is a fixed buffer size.有界缓冲对缓冲区大小作了限定有界缓冲对缓冲区大小作了限定Bounded-Buffer Shared-Memory SolutionnShared datavar n;type item=;var buffer.array 0.n1 of item;in,out:0.n1;nProducer process repeatproduce an item in nextpwhile in+1 mod n=out do

22、no-op;buffer in:=nextp;in:=in+1 mod n;until false;Bounded-Buffer(Cont.)nConsumer process repeatwhile in=out do no-op;nextc:=buffer out;out:=out+1 mod n;consume the item in nextc until false;nSolution is correct,but can only fill up n1 buffer.ThreadsnA thread(or lightweight process)is a basic unit of

23、 CPU utilization;it consists of:nprogram counternregister setnstack spacenA thread shares with its peer threads its:ncode sectionndata sectionnoperating-system resourcescollectively know as a task.整体作为一个任务整体作为一个任务Threads(Cont.)nIn a multiple threaded task,while one server thread is blocked and waiti

24、ng,a second thread in the same task can run.nCooperation of multiple threads in same job confers higher throughput and improved performance.nApplications that require sharing a common buffer(i.e.,producer-consumer)benefit from thread utilization.nThreads provide a mechanism that allows sequential pr

25、ocesses to make blocking system calls while also achieving parallelism.nKernel-supported threads(Mach and OS/2).nUser-level threads;supported above the kernel,via a set of library calls at the user level.nHybrid approach implements both user-level and kernel-supported threads(Solaris 2).混合处理实现用户级和内核

26、支持线程Interprocess Communication-IPCnMechanism for processes to communicate and to synchronize their actions.nMessage system processes communicate with each other without resorting to shared variables.nIPC facility provides two operationsnsend(message)message size fixed or variablenreceive(message)nIf

27、 P and Q wish to communicate,they need to:nestablish a communication link between themnexchange messages via send/receivenImplementation of communication linknphysical(e.g.,shared memory,hardware bus)nlogical(e.g.,logical properties)Implementation QuestionsnHow are links established?nCan a link be a

28、ssociated with more than two processes?nHow many links can there be between every pair of communicating processes?nWhat is the capacity of a link??nIs the size of a message that the link can accommodate fixed or variable?nIs a link unidirectional or bi-directional?Direct CommunicationnProcesses must

29、 name each other explicitly显式显式:nsend(P,message)send a message to process Pnreceive(Q,message)receive a message from process QnProperties of communication linknLinks are established automatically.nA link is associated with exactly one pair of communicating processes.nBetween each pair there exists e

30、xactly one link.nThe link may be unidirectional,but is usually bi-directional.Indirect CommunicationnMessages are directed and received from mailboxes.nEach mailbox has a unique id.nProcesses can communicate only if they share a mailbox.nProperties of communication linknLink established only if proc

31、esses share a common mailbox nA link may be associated with many processes.nEach pair of processes may share several communication links.nLink may be unidirectional.nal or bi-directional.nOperationsncreate a new mailboxnsend and receive messages through mailboxndestroy a mailboxTypes of MailboxnPriv

32、ate Mailbox:owner-Receive other user-SendnPublic Mailbox:owned by OSnShared Mailbox:created by a process,the ownership and privilege be passed to other processesSynchronizationnBlocking send:sender blocked until the message is receivednNonblocking send:send the message and resume operationnBlocking

33、receive:receiver blocked until a message is availablenNonblocking receive:receiver retrieves either a valid message or nullBufferingnQueue of messages attached to the link;implemented in one of three ways.1.Zero capacity 0 messages Sender must wait for receiver.2.Bounded capacity finite length of n messages Sender must wait if link full.3.Unbounded capacity infinite length Sender never waits.Exception Conditions Error RecoverynProcess terminates 进程终止进程终止nLost messages 消息丢失消息丢失nScrambled Messages 消息受损消息受损HomeworknP113 n4.1n4.4n4.6

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服