confide

导航

2011年8月15日 #

unix编程——信号量

摘要: 线程间同步:生产者与消费者问题,分别为一个线程执行生产消费,信号量则在进程空间中共享。sem.c:#include <stdio.h>#include <stdlib.h>#include <semaphore.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h>sem_t *put;sem_t *get;int nitems;int curr;void*producer(){ while(1){ sem_wait(put); if(curr > n 阅读全文

posted @ 2011-08-15 16:00 confide 阅读(360) 评论(0) 推荐(0)