首页 > 试题广场 >

生产者与消费者分别利用计数信号量empty. full并借助

[问答题]

生产者与消费者分别利用计数信号量empty. full并借助单缓冲buffer进行数据传输:

var empty, full: semaphore: =1,0;
begin                                                      consuner: begin
parbeging                                               repeat
producer: begin                                             (C)
repeat                                                    nextc:   =buffer;
produce an item  in nextp;                                      (D)   
(A)                                                         consume   the   item   in   nextc;
buffer: =nextp;                                            until false;
(B)                                                         end
until   false;                                              parend
end                                                         end

选择答案:

( 1 ) wait(full)     (2 ) wait(empty)     (3 ) signal(ful)     (4 ) signal(empty)

1
发表于 2020-05-06 18:08:30 回复(0)