摘要: 1 # define N 5 2 # define LEFT (i + N - 1) % N 3 # define RIGHT (i + 1) % N 4 # define THINKING 0 5 # define HUNGRY 1 6 # define EATING 2 7 typedef in 阅读全文
posted @ 2021-04-18 16:20 解忧swag 阅读(81) 评论(0) 推荐(0)
摘要: 1 typedef int semaphore; 2 semaphore count_mutex = 1; 3 semaphore data_mutex = 1; 4 int count = 0; 5 6 void reader(){ 7 while(TRUE){ 8 down(&count_mut 阅读全文
posted @ 2021-04-18 16:00 解忧swag 阅读(52) 评论(0) 推荐(0)
摘要: 1 # define N 100 2 typedef int semaphore; 3 semaphore mutex = 1; 4 semaphore empty = N; 5 semaphore full = 0; 6 7 void produce(){ 8 while(TRUE){ 9 int 阅读全文
posted @ 2021-04-18 15:30 解忧swag 阅读(112) 评论(0) 推荐(0)