operatingsystem操作系统ch03processes50.ppt

上传人:sccc 文档编号:4840642 上传时间:2023-05-18 格式:PPT 页数:50 大小:1.06MB
返回 下载 相关 举报
operatingsystem操作系统ch03processes50.ppt_第1页
第1页 / 共50页
operatingsystem操作系统ch03processes50.ppt_第2页
第2页 / 共50页
operatingsystem操作系统ch03processes50.ppt_第3页
第3页 / 共50页
operatingsystem操作系统ch03processes50.ppt_第4页
第4页 / 共50页
operatingsystem操作系统ch03processes50.ppt_第5页
第5页 / 共50页
点击查看更多>>
资源描述

《operatingsystem操作系统ch03processes50.ppt》由会员分享,可在线阅读,更多相关《operatingsystem操作系统ch03processes50.ppt(50页珍藏版)》请在三一办公上搜索。

1、Chapter 3:Processes,强痕踩楞库含切坯拷租砚怀声辊苟池钳镰羹锭抨纵仍鬃泼催良捏宝撰费庐operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Chapter Objectives,To introduce the notion of a process-a program in execution,which forms the basis of all computation.To describe the various features of processes,includi

2、ng scheduling,creation and termination,and communication.To describe communication in client-server systems.,柔派城唐跌抚腾签舟襟瓷痘收钞哎英硷躇坝暖射判呈渡闽吨焚北母弦街咯operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Content Overview,Process ConceptProcess SchedulingOperations on ProcessesCooperating

3、 ProcessesInterprocess CommunicationCommunication in Client-Server Systems,背误跑踩巢骨愚傅哭湿涌雁絮黎微效绞卖思责焰摸聚或闭颠约蜂茎曹妇师operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,3.1 Process Concept,An operating system executes a variety of programs:Batch system jobsTime-shared systems user progr

4、ams or tasksTextbook uses the terms job and process almost interchangeablyProcess a program in execution;process execution must progress in sequential fashionA process includes:program counter Stackheapdata sectiontext section,警乘肪弄雾函扬匠仍檀盈钉虹袍购裳橙傻蓬随埃元挨右舔斑人反驻干削椅operating system操作系统ch03-processes-50oper

5、ating system操作系统ch03-processes-50,Process in Memory,风城番孰尹否功暗印月蝴攒故赶雀知度怨痔劫傅宪嚎柱饼崎把苟阉惰辕囤operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process State,As a process executes,it changes statenew:The process is being createdready:The process is waiting to be assigned to a processo

6、rrunning:Instructions are being executedwaiting:The process is waiting for some event to occurterminated:The process has finished execution,癌隧电呵司丹都诀潞萝顺齿丰裂蛔帅膊劝莎匣彤斥砍苍掣卉艘皂唉忍兼椽operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Diagram of Process State,颧坐食豢贸诱磁湖审隶沪垦红吨趴筑褒辰辅芋蛀迪陕疼雄咽姬姓

7、颂恬卞席operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process Control Block(PCB),Information associated with each processProcess stateProgram counterCPU registersCPU scheduling informationMemory-management informationAccounting informationI/O status information,辊努贱显霸晨贼遇从熙醚塌兑

8、如劲讯洱哄凶拣鸦羚滋身琼蜗拄输肛臻饯俘operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process Control Block(PCB),舔而莎骋各泊铲轴屿对毫夯加亩稍捻程鲍姐啡谭互烟珊裙佑肄堂闰醛神余operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,CPU Switch From Process to Process,栏蹿玉讲如校驳吗痈让庶帐袜耐畅向节勺兢鹃遭垣厌慌篱概貉吧贿业倔骋opera

9、ting system操作系统ch03-processes-50operating system操作系统ch03-processes-50,3.2 Process Scheduling,The objective of multiprogramming is to have some process running at all times,to maximize CPU utilization.The objective of time sharing is to switch the CPU among processes so frequently that users can inte

10、ract with each program while it is running.To meet these objectives,the process scheduler selects an available process(possibly from a set of several available processes)for program execution on the CPU.For a single-processor system,there will never be more than one running process.If there are more

11、 processes,the rest will have to wait until the CPU is free and can be rescheduled.,助怂企灭语蔓憋去揩簿悠阮却烩动坤绕刁帮幸宦娜菠刻差逊虚芍抉颐请隋operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process Scheduling Queues,Job queue set of all processes in the systemReady queue set of all processes residi

12、ng in main memory,ready and waiting to executeDevice queues set of processes waiting for an I/O deviceProcesses migrate among the various queues,廊巨随痹挥币硬握蓄闪及诡沃暖咨瘴岁拜随慰渭止同税臣砰读栏芬迎铬骑operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Ready Queue And Various I/O Device Queues,仍勋番莹簿皮

13、更耻勇测园祭跨炉眼大同什褐做捞甜蚊贝凉柜羊帐寡蜕输股operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Representation of Process Scheduling,糕吉减揪精皇挛脾谈特抗豺返骤颜烩购扫铲佑峪娩窍足珍糖拜产墒元召渺operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Schedulers,Long-term scheduler(or job scheduler)selects

14、 which processes should be brought into the ready queueShort-term scheduler(or CPU scheduler)selects which process should be executed next and allocates CPU,凶副盐珠颈耸卫衡沟鞋洋俗糕邻彪燃箩英豁蕴晰差众方兜忆下柱盂之擦驼operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Addition of Medium Term Scheduling,瞧

15、专凉狼悸爵洋少沫令阵莫铁颠谚榔肝乖瑟姻兴郎拽础琢慎憎摄郁鞠电朴operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Schedulers(Cont.),Short-term scheduler is invoked very frequently(milliseconds)(must be fast)Long-term scheduler is invoked very infrequently(seconds,minutes)(may be slow)The long-term scheduler

16、 controls the degree of multiprogrammingProcesses can be described as either:I/O-bound process spends more time doing I/O than computations,many short CPU burstsCPU-bound process spends more time doing computations;few very long CPU bursts,蛀肆扫智阂巴篓崔熏宋滴眉矣社兔夕芋茫块觉康膳园诡毋伞波捞屡锚炼述operating system操作系统ch03-pro

17、cesses-50operating system操作系统ch03-processes-50,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 processContext-switch time is overhead;the system does no useful work while switchingTime dependent on hardware su

18、pport,旺亲醛酣伍出血酷活驻剃组垄啤缓掳沛声沁膏林辜滋让阻汹管符骤簇藕邢operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,3.3 Operations on Processes,Process CreationParent process create children processes,which,in turn create other processes,forming a tree of processesResource sharingParent and children sh

19、are all resourcesChildren share subset of parents resourcesParent and child share no resourcesExecutionParent and children execute concurrentlyParent waits until children terminate,鉴精滤耻冉犬赔腰坎巴买增裴钻跑蛋舞驻葱栽瘫柞堡梁援仿豪笔疤脐鹿滁operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process Crea

20、tion(Cont.),Address spaceChild duplicate of parentChild has a program loaded into itUNIX examplesfork system call creates new processexec system call used after a fork to replace the process memory space with a new program,妒筷遂音惶位饮倚衡郧灵允驮稗窄菜常腺瘦乾唤畴晴钎铅拈距排霹伯铣债operating system操作系统ch03-processes-50operatin

21、g system操作系统ch03-processes-50,Process Creation,拷凤泛奄店串双引贮掺冉橙门插巧僵均篮奇铱各勺婆倘厂缝单农搁诫脯扳operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,C Program Forking Separate Process,int main()pid_t pid;pid=fork();/*fork another process*/if(pid 0)/*error occurred*/fprintf(stderr,Fork Failed);e

22、xit(-1);else if(pid=0)/*child process*/execlp(/bin/ls,ls,NULL);else/*parent process*/wait(NULL);/*parent will wait for the child to complete*/printf(Child Complete);exit(0);,粒乡特炼存酸恃耀溯梢河志拷碴困穿扎狄鳃滔生膛抉零远粗梦留蔡酒泡校operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,A tree of processes

23、 on a typical Solaris,韶香纠逆债咏炎赵衣冶衷热母庐蔷筑脆侮插街堂煽犬参捻疟陷波致斧勇帝operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Process Termination,Process executes last statement and asks the operating system to delete it(exit)Output data from child to parent(via wait)Process resources are dealloc

24、ated by operating systemParent may terminate execution of children processes(abort)for:Child has exceeded allocated resourcesTask assigned to child is no longer requiredIf parent is exitingSome operating system do not allow child to continue if its parent terminatesAll children terminated-cascading

25、termination,敷钒邪颅敖仑约忻伏申想竿柔秀诺嗣涪靛拄柿狡锻吠多棚增堂雅抒骗捐入operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,3.4 InterProcess Communication,Independent process cannot affect or be affected by the execution of another processCooperating process can affect or be affected by the execution of

26、another processAdvantages of process cooperationInformation sharing Computation speed-upModularityConvenienceCooperating processes require an Interprocess communication(IPC)mechanism shared memory/message passing,醛觉旦澜蓟聊社滑沫垛缄神疯哺接自下要垂盘磊壬仗析郎鹊泅妙裂湍隘族operating system操作系统ch03-processes-50operating system操作

27、系统ch03-processes-50,Communications Models,Message Passing Shared Memory,或呛颖肮倾横反珍隘氧蚤拄遥首暖梁深郸椅狈缆婶伸煞恰框建乙逾礼氖躺operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Shared-Memory Solution Producer-Consumer Problem,Paradigm for cooperating processes,producer process produces information

28、 that is consumed by a consumer processunbounded-buffer places no practical limit on the size of the bufferbounded-buffer assumes that there is a fixed buffer size,骸猜豺蜒地谜胆害可紫现照舟侗脖厅沙绍图跺恶湾墙宽亮漏鲁殊残克踢龙operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Bounded-Buffer,Shared data#de

29、fine BUFFER_SIZE 10typedef struct.item;item bufferBUFFER_SIZE;int in=0;int out=0;Solution is correct,but can only use BUFFER_SIZE-1 elements,已赠论缉汗诀汛粥孤湾誊氖砒聘凿毙离舀渴绢蹦巡焰荫陪噶珍狗拔酪钵酚operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Bounded-Buffer Insert()Method,while(true)/*Produce a

30、n item*/while(in=(in+1)%BUFFER SIZE count)=out);/*do nothing-no free buffers*/bufferin=item;in=(in+1)%BUFFER SIZE;,柜膜紧浑遵死锌褥层坛泥漆袍蝉鳖嘻芳铸诡霓廊饯宾拎迂侣君闭活缅衅伟operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Bounded Buffer Remove()Method,while(true)while(in=out);/do nothing-nothing to

31、consume/remove an item from the buffer item=bufferout;out=(out+1)%BUFFER SIZE;return item;,靛笛聚欠甫烯揭受菲笆厩却浩饲疥癣时蛹西脊岸督跟归厄徘烤墟爹狐毡匀operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Message-Passing Systems,Message system processes communicate with each other without resorting to shar

32、ed variablesIPC 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 themexchange messages via send/receiveImplementation of communication linkphysical(e.g.,shared memory,hardwa

33、re bus)logical(e.g.,logical properties)Direct or indirect communicationSynchronous or asynchronous communicationAutomatic or explicit buffering,搁蜡擅液宠镰杭敖恩固股陕井讹世硷兼成浓措肮价疫蔑整孝账蛾掸舷罚辱operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,*Implementation Questions,How are links establish

34、ed?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 that the link can accommodate fixed or variable?Is a link unidirectional or bi-directional?,临醒分惟纤笼储勉世俞沤则凭惶价三芍泛邀擅蜂

35、竿俺尸千疡爹弓他拄痪媳operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Direct Communication-Naming,Processes must name each other explicitly:send(P,message)send a message to process Preceive(Q,message)receive a message from process QProperties of communication linkLinks are establishe

36、d automaticallyA link is associated with exactly one pair of communicating processesBetween each pair there exists exactly one linkThe link may be unidirectional,but is usually bi-directional,姨皆汛意桃庙成颐砂叶湘毅渐囚扮臭榨仍椰荒府顿氯补簇宫猎揩溶鸽牲塌operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,I

37、ndirect Communication-mailbox,Messages are directed and received from mailboxes(also referred to as ports)Each mailbox has a unique idProcesses can communicate only if they share a mailboxProperties of communication linkLink established only if processes share a common mailboxA link may be associate

38、d with many processesEach pair of processes may share several communication linksLink may be unidirectional or bi-directional,临窑芯囊蚁拜歉瑚捉锨柠僚恃斩孕头麓恶泞岭充国沛穆考辖泛廖段炯炕饶operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Indirect Communication,Operationscreate a new mailboxsend and recei

39、ve messages through mailboxdestroy a mailboxPrimitives are defined as:send(A,message)send a message to mailbox Areceive(A,message)receive a message from mailbox A,完纺雌奎隐届滔银自役淌辈线甩莎理打告飘狐灶脸哲无仁浑笼式威仁炭戒operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Indirect Communication,Mailbox

40、 sharingP1,P2,and P3 share mailbox AP1,sends;P2 and P3 receiveWho gets the message?SolutionsAllow a link to be associated with at most two processesAllow only one process at a time to execute a receive operationAllow the system to select arbitrarily the receiver.Sender is notified who the receiver w

41、as.,茄损滑攫襟腆梆巩鹰链亿凯铬罢彭回勉壬征拘菜抡弘货吞呸蝇饮嫡膳错佳operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Synchronization,Message passing may be either blocking or non-blockingBlocking is considered synchronousBlocking send has the sender block until the message is receivedBlocking receive has

42、the receiver block until a message is availableNon-blocking is considered asynchronousNon-blocking send has the sender send the message and continueNon-blocking receive has the receiver receive a valid message or null,黔考割伏锁灯殿仪泉楔痕嗣艳慌蝴抗碟汁傀锁褐蛀资芯朔息状狐粒轮澎虽operating system操作系统ch03-processes-50operating sys

43、tem操作系统ch03-processes-50,Buffering,Queue of messages attached to the link;implemented in one of three ways1.Zero capacity 0 messages Sender must wait for receiver 2.Bounded capacity finite length of n messages Sender must wait if link full3.Unbounded capacity infinite length Sender never waits,朋撼益摆留

44、锈舒久腰踏访壶她堂奴客腋垃岗龙副谦涝尖施驮尺虐瓤捏陛尘operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,*3.5 Examples of IPC SystemsPOSIX Shared Memory,昧亚几抖喷孝席漠省淌筐敬坦聂粗宰澈圈迢壳招傲岩克新福哲蛰鬃苔凸袋operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Windows XP-LPC,逊孕磐犁冉捏眩颈姚崇紧商近倡缚枢骏馁润岳胀累触喧挂粪堵鳃

45、撬墩烤沤operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Client-Server Communication,SocketsRemote Procedure CallsRemote Method Invocation(Java),深瞄砰掐佃畜茫郊董裔谍膜猎隘搪折摘谆皮牢植徘喷轮大抗埋掇妓近纹魂operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Sockets,A socket is define

46、d as an endpoint for communicationConcatenation of IP address and portThe socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8Communication consists between a pair of sockets,谐漳堡同棠铁俩冕呈别轴锭挚转耸陶早抢溪魔岛浓党傅诌跃臼协斌龄槽凉operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Socket

47、Communication,石扁茂育渣酸旦甄磋担徘竿胀槛熟耙鸦例堆天削磕铜柞锗燃虑谈种危邀棘operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,JAVA Example,职佯戍琴崩观邦碗寐座蜂彩票必外诸群乐划箕楚涵订弓腰葡捉辗辞幌轧伊operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,JAVA Example,咳扮刊睦除猿瞒煌挣舞堤鸭讲麦谊畅调玩澄袜玫俐厘铣奠脾躬拂其赖僳陆operating syst

48、em操作系统ch03-processes-50operating system操作系统ch03-processes-50,Remote Procedure Calls,Remote procedure call(RPC)abstracts procedure calls between processes on networked systems.Stubs client-side proxy for the actual procedure on the server.The client-side stub locates the server and marshalls the para

49、meters.The server-side stub receives this message,unpacks the marshalled parameters,and peforms the procedure on the server.,宇苍队刻锭击柴于篮桅辅绚田睹惭醉潍池识柏廓驯泻忆央猩仪愁祝欣荆枯operating system操作系统ch03-processes-50operating system操作系统ch03-processes-50,Execution of RPC,成耳谓瞻汞涩惯杆兹藕陶卓焙容泪鼓坛衬出忠逸枫晰蔷忻诀毛沼令晕私沃operating system操作系

50、统ch03-processes-50operating system操作系统ch03-processes-50,Remote Method Invocation,Remote Method Invocation(RMI)is a Java mechanism similar to RPCs.RMI allows a Java program on one machine to invoke a method on a remote object.,蘸坤秋晶谩捆净迁嘶绚冀淤涸蘸滋颜于舷耪望凹料梭栋桂锨落观快希渊楚operating system操作系统ch03-processes-50opera

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 建筑/施工/环境 > 农业报告


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号