?? semgetvalues.c
字號:
#include "unpipc.h"
int
main(int argc, char **argv)
{
int semid, nsems, i;
struct semid_ds seminfo;
unsigned short *ptr;
union semun arg;
if (argc != 2)
err_quit("usage: semgetvalues <pathname>");
/* 4first get the number of semaphores in the set */
semid = Semget(Ftok(argv[1], 0), 0, 0);
arg.buf = &seminfo;
Semctl(semid, 0, IPC_STAT, arg);
nsems = arg.buf->sem_nsems;
/* 4allocate memory to hold all the values in the set */
ptr = Calloc(nsems, sizeof(unsigned short));
arg.array = ptr;
/* 4fetch the values and print */
Semctl(semid, 0, GETALL, arg);
for (i = 0; i < nsems; i++)
printf("semval[%d] = %d\n", i, ptr[i]);
exit(0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -