计算机操作系统中生产者消费者问题管程实现.pdfVIP

  • 2
  • 0
  • 约1.64千字
  • 约 6页
  • 2026-02-27 发布于北京
  • 举报

计算机操作系统中生产者消费者问题管程实现.pdf

监视器PC;intnextin,nextout,

count;charbuffer[[]];condition

notfull,notempty;append(charx)

{if(count==])Cwait(notfull);

buffer[nextin]=x;nextin=(nextin+1)

%n;count++;Csignal(notempty);}

take(charx){if(count==0)

Cwait(notempty);x=

buffer[nextout];nextout=(nextout+1)

%n;count‑‑;Csignal(notfull);}{

count=0;nextin=0;nextout=0

MonitorPC;

intnextin,nextout,count;

charbuffer[n];

conditionnotfull,notempty;

append(charx)

{

if(count==n)Cwait(notfull);

buffer(nextin)=x;

nex

文档评论(0)

1亿VIP精品文档

相关文档