摘要: 题目要求:父亲往盘子里放水果(苹果和香蕉),儿子只能取苹果,女儿只能取香蕉,使用信号量的线程同步实验实现该程序。源码: 1 #include <stdio.h> 2 #include <string.h> 3 #include <semaphore.h> 4 #include <pthread.h> 5 #include <sys/types.h> 6 #include <unistd.h> 7 sem_t sp; //定义信号量 8 sem_t sa; //父亲放香蕉,女儿取水果(香蕉) 9 sem_t so; //父亲 阅读全文
posted @ 2013-05-23 11:43 蓬莱仙羽 阅读(368) 评论(0) 推荐(1) 编辑