当前位置: 技术问答>linux和unix
一个关于linux的信号量集的问题
来源: 互联网 发布时间:2016-07-10
本文导语: #include #include #include union semun{ int val; struct semid_ds *buf; unsigned short *array; } main() { int semid; semid=semget(IPC_PRIVATE,2,IPC_CREAT|0666); union semun sem,sem2; sem.val=1; sem2.val=0; semctl(semid,0,SETVAL,sem); semctl(semid,1,SETVAL,sem2); if(fork()==0) ...
#include
#include
#include
union semun{
int val;
struct semid_ds *buf;
unsigned short *array;
}
main()
{
int semid;
semid=semget(IPC_PRIVATE,2,IPC_CREAT|0666);
union semun sem,sem2;
sem.val=1;
sem2.val=0;
semctl(semid,0,SETVAL,sem);
semctl(semid,1,SETVAL,sem2);
if(fork()==0)
{int i;
struct sembuf sops={0,+1,IPC_NOWAIT},sops2={1,-1,IPC_NOWAIT};
for(i=0;i
#include
#include
union semun{
int val;
struct semid_ds *buf;
unsigned short *array;
}
main()
{
int semid;
semid=semget(IPC_PRIVATE,2,IPC_CREAT|0666);
union semun sem,sem2;
sem.val=1;
sem2.val=0;
semctl(semid,0,SETVAL,sem);
semctl(semid,1,SETVAL,sem2);
if(fork()==0)
{int i;
struct sembuf sops={0,+1,IPC_NOWAIT},sops2={1,-1,IPC_NOWAIT};
for(i=0;i