homework-4 Version 0 |
|
👤 Author: by 2706197253qqcom 2019-10-09 04:37:27 |
Think about your possible case about process synchronization, and give out a solution for the problem.
The proceducer-consumer problem:
When solving producer-consumer problems by pipeline method, the first step is to establish a pipeline for them, which is named Proclucer Consumer, or PC for short. There are two processes:
Put (item) process. Producers use this process to put their products into the buffer pool, and use the integer variable count to represent the number of products in the buffer pool. When count (> n), the buffer pool is full and the producer has to wait.
Get (item) process. Consumers use this process to extract a product from the buffer pool. When count is less than 0, it indicates that there is no product available in the buffer pool. Consumers should wait.