当前位置: 技术问答>linux和unix
求救 ~~~~~linux下进行c语言编程问题
来源: 互联网 发布时间:2016-07-20
本文导语: #include #include #include #include #include #include #include #include /* union semun { int val; struct semid_ds *buf; unsigned short int *array; struct seminfo *__buf; }; */ int rcounter; //读者数量 int wcounter; //写者数量 pid_t pid; int i; ...
#include
#include
#include
#include
#include
#include
#include
#include
/*
union semun
{
int val;
struct semid_ds *buf;
unsigned short int *array;
struct seminfo *__buf;
};
*/
int rcounter; //读者数量
int wcounter; //写者数量
pid_t pid;
int i;
int semid;
key_t key;
//union semun arg;
int val;
int main()
{
int Semset(int sid,int semnum,int n);
int P(int sid,int semnum,int n);
int V(int sid,int semnum,int n);
val=1;
/*创建信号集
0123信号量分别作用如下
sem_t db; //实现写写互斥 ---0
sem_t mutex; //实现读写互斥 ---1
sem_t wc_mutex; //对wcounter实行访问互斥 ---2
sem_t rc_mutex; //rcounter实行访问互斥 ---3
*/
if((key=ftok(".",1))