核心算法为生产者进程与消费者进程的PV操作 其余的都是简单模拟
#include<cstdio>
#include<Windows.h>
#include<iostream>
#define maxsize 5 //缓冲区大小
typedef int semaphore; //信号量
typedef int production;//物品
semaphore mutex = 1;
semaphore empty = maxsize;
semaphore full = 0;
semaphore buffer[maxsize];//缓冲池数组
static int buffersize = 0;//当前缓冲池元素个数
void producer_Thread(); //生产者进程
void consumer_Thread(