#include <sys/types.h> |
#include <sys/ipc.h> |
#include <sys/sem.h> |
int semop(int semid, struct sembuf *sops, unsigned nsops); |
/* semop system calls takes an array of these. */
struct sembuf {
unsigned short sem_num; /* semaphore index in array */
short sem_op; /* semaphore operation */
short sem_flg; /* operation flags */
};
sem_op 的值的含义: sem_op < 0 对应于资源的分配;信号加上 sem_op 的值,若没有设置 IPC_NOWAIT ,则调用进程阻塞,直到资源可用;否则进层直接返回 EAGAIN 。 sem_op =0 如果没有设置 IPC_NOWAIT ,则调用进程进入睡眠状态,直到信号值为 0 ;否则进程不会睡眠,直接返回 EAGAIN 。 sem_op > 0 表示进程释放控制的资源。 |
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |