【正确答案】此题主要考查进程间共享缓)中区来实现同步的相关内容。 int mutex=1 int empty=n; int full=0; int in=0; int out=0; main(){ cobegin send(); obtain(); coend } send(){ while(1){ ...... collect data in nextp wait (empty); wait (mutex); buffer (in)=nextp; in=(in+1)mod n; signal(mutex); signal (full); } }//send obtain(){ while(1){ wait(full); wait(mutex); nextc:=buffer(out); out:=(out+1)mod n; signal (mutex); signal (empty); culculate the data in nextc; }//while }//obtain
【答案解析】