信号量的应用 利用信号量实现进程互斥利用信号量实现进程互斥的进程可描述如下 Var mutex:semaphore∶=; begin parbegin process : begin repeat wait(mutex); critical section signal(mutex); remainder seetion until false; end process : begin repeat wait(mutex); critical section signal(mutex); remainder section until false; end parend 利用信号量实现前趋关系 Var abcdefg; semaphore∶=; begin parbegin begin S; signal(a); signal(b); end; begin wait(a); S; signal(c); signal(d); end; begin wait(b); S; signal(e); end; begin wait(c); S; signal(f); end; begin wait(d); S; signal(g); end; begin wait(e); wait(f); wait(g); S; end; parend end ——返回教材目录 了解更多计算机相关基础课程视频 [] [] [] |