《操作系统进程管理习题课件.ppt》由会员分享,可在线阅读,更多相关《操作系统进程管理习题课件.ppt(8页珍藏版)》请在三一文库上搜索。
1、操作系统进程管理习题,1,2. 试画出下面四条语句的前趋图: S1: a:=x+y S2: b:=z+1 S3: c:=a-b S4: w:=c+1,操作系统进程管理习题,2,图 2-2题 四条语句的前趋关系,操作系统进程管理习题,3,26. 试修改下面生产者消费者问题解法中的错误:,操作系统进程管理习题,4,Var mutex, empty, full: semaphore:=1,n,0; buffer: array0, , n-1 of item; in, out: integer:=0, 0; begin parbegin producer: begin repeat producer
2、an item nextp; wait(mutex); wait(empty); wait(full); wait(mutex); buffer(in):=nextp; ; in:=in+1 mod n; signal(mutex); ; signal(full); until false; end,操作系统进程管理习题,5,consumer: begin repeat wait(mutex); wait(full); wait(empty); wait(mutex); nextc:=buffer(out); out:=(out+1); out:=(out+1) mod n; signal(m
3、utex); ; signal(empty); consumer the item in nextc; until false; end parend end,操作系统进程管理习题,6,Var mutex, empty, full: semaphore:=1,n,0; buffer: array0, , n-1 of item; in, out: integer:=0, 0; begin parbegin producer: begin repeat producer an item nextp; wait(empty); wait(mutex); buffer(in):=nextp; in:
4、=(in+1) mod n; signal(mutex); signal(full); until false; end,操作系统进程管理习题,7,consumer: begin repeat wait(full); wait(mutex); nextc:=buffer(out); out:=(out+1) mod n; signal(mutex); signal(empty); consumer the item in nextc; until false; end parend end,操作系统进程管理习题,8,27 哲学家进餐问题,1. Var chopstick: array0, , 4 of semaphore;,