Buffer B;
Semaphore empty = 1;
Semaphore full = 0;
process producer(){
while (true){
produce();
P(empty);
append() to B;
V(full);
}
}
process consumer(){
while (true){
P(full);
take() from B;
V(empty);
consume();
}
}
单缓冲区--生产者-消费者问题
最新推荐文章于 2023-09-23 16:24:24 发布