sem_post函数的定义及作用
sem_post函数的定义及作用
1、sem_post
的基本定义
#include <semaphore.h> int sem_post(sem_t *sem);
功能:
将信号量
sem
的值加 1。如果有线程因为
sem_wait
阻塞,那么 会唤醒其中一个线程。
返回值:
成功返回
0
失败返回
-1
,并设置errno
1、sem_post
的基本定义
#include <semaphore.h> int sem_post(sem_t *sem);
功能:
将信号量 sem
的值加 1。
如果有线程因为 sem_wait
阻塞,那么 会唤醒其中一个线程。
返回值:
成功返回 0
失败返回 -1
,并设置 errno