操作系统经典 pv过桥问题
Semophere bridge=1;Semophere mutexNS=1,mutexSN=1;//用于保护countNS,countSN int countNS=0,countSN=0; Semophere s1=1,s2=0;//用于交替通过 StoN(){ while(1){ P(mutexSN); countSN++;//来车了 v(mutexSN); p(mutexSN); if(countNS==0){//对面无车,则直接通过 P(bridge).
原创
2021-12-15 15:58:55 ·
2851 阅读 ·
0 评论