计算机操作系统(第三版)汤小丹 梁红兵 汤小瀛西安电子科技大学出版社
until false;
end
process 2: begin
repeat
wait(mutex);
critical section
signal(mutex);
remainder section
until false;
end
parend
22.试写出相应的程序来描述图2-17所示的前驱图。
答:(a)Var a, b, c, d, e, f, g, h; semaphore:= 0, 0, 0, 0, 0, 0, 0, 0;
begin
parbegin
begin S1; signal(a); signal(b); end;
begin wait(a); S2; signal(c); signal(d); end;
begin wait(b); S3; signal(e); end;
begin wait(c); S4; signal(f); end;
begin wait(d); S5; signal(g); end;
begin wait(e); S6; signal(h); end;
begin wait(f); wait(g); wait(h); S7; end;
parend
end
(b)Var a, b, c, d, e, f, g, h,i,j; semaphore:= 0, 0, 0, 0, 0, 0, 0,0,0, 0;
begin
parbegin
begin S1; signal(a); signal(b); end;
begin wait(a); S2; signal(c); signal(d); end;
begin wait(b); S3; signal(e); signal(f); end;
begin wait(c); S4; signal(g); end;
begin wait(d); S5; signal(h); end;
begin wait(e); S6; signal(i); end;
begin wait(f); S7; signal(j); end;
begin wait(g);wait(h); wait(i); wait(j); S8; end;
parend