函数 | |
STATIC INLINE INT32 | CondInitCheck (const pthread_cond_t *cond) |
int | pthread_condattr_getpshared (const pthread_condattr_t *attr, int *shared) |
获取条件变量的范围,目前只支持获取PTHREAD_PROCESS_PRIVATE条件变量属性 更多... | |
int | pthread_condattr_setpshared (pthread_condattr_t *attr, int shared) |
设置条件变量的范围 更多... | |
int | pthread_condattr_destroy (pthread_condattr_t *attr) |
销毁条件变量属性对象 更多... | |
int | pthread_condattr_init (pthread_condattr_t *attr) |
初始化条件变量属性对象 更多... | |
int | pthread_cond_destroy (pthread_cond_t *cond) |
销毁条件变量 更多... | |
int | pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) |
pthread_cond_init 初始化条件变量 更多... | |
STATIC VOID | PthreadCondValueModify (pthread_cond_t *cond) |
int | pthread_cond_broadcast (pthread_cond_t *cond) |
解除若干已被等待条件阻塞的线程 更多... | |
int | pthread_cond_signal (pthread_cond_t *cond) |
解除被阻塞的线程/发送满足条件信号量 更多... | |
STATIC INT32 | PthreadCondWaitSub (pthread_cond_t *cond, INT32 value, UINT32 ticks) |
STATIC VOID | PthreadCountSub (pthread_cond_t *cond) |
STATIC INT32 | ProcessReturnVal (pthread_cond_t *cond, INT32 val) |
int | pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *absTime) |
pthread_cond_timedwait 等待条件 在指定的时间之前阻塞,函数会一直阻塞,直到该条件获得信号,或者最后一个参数所指定的时间已过为止。 更多... | |
int | pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) |
阻塞方式获取条件变量,阻塞的线程可以通过 pthread_cond_signal() 或 pthread_cond_broadcast() 唤醒 更多... | |
条件变量属性 使用条件变量可以以原子方式阻塞线程,直到某个特定条件为真为止。条件变量始终与互斥锁一起使用。 使用条件变量,线程可以以原子方式阻塞,直到满足某个条件为止。对条件的测试是在互斥锁(互斥)的保护下进行的。 如果条件为假,线程通常会基于条件变量阻塞,并以原子方式释放等待条件变化的互斥锁。如果另一个线程更改了条件, 该线程可能会向相关的条件变量发出信号,从而使一个或多个等待的线程执行以下操作: 唤醒 再次获取互斥锁 重新评估条件 在以下情况下,条件变量可用于在进程之间同步线程: 线程是在可以写入的内存中分配的 内存由协作进程共享 调度策略可确定唤醒阻塞线程的方式。对于缺省值 SCHED_OTHER,将按优先级顺序唤醒线程。 https://docs.oracle.com/cd/E19253-01/819-7051/sync-13528/index.html https://docs.oracle.com/cd/E19253-01/819-7051/6n919hpai/index.html#sync-59145 *
在文件 pthread_cond.c 中定义.
STATIC INLINE INT32 CondInitCheck | ( | const pthread_cond_t * | cond | ) |
int pthread_cond_broadcast | ( | pthread_cond_t * | cond | ) |
解除若干已被等待条件阻塞的线程
在文件 pthread_cond.c 第 189 行定义.
int pthread_cond_destroy | ( | pthread_cond_t * | cond | ) |
销毁条件变量
在文件 pthread_cond.c 第 119 行定义.
int pthread_cond_init | ( | pthread_cond_t * | cond, |
const pthread_condattr_t * | attr | ||
) |
pthread_cond_init 初始化条件变量
attr | 指向条件变量属性的指针,若为 NULL 则使用默认属性值 |
cond | 条件变量句柄,不能为 NULL |
在文件 pthread_cond.c 第 150 行定义.
int pthread_cond_signal | ( | pthread_cond_t * | cond | ) |
解除被阻塞的线程/发送满足条件信号量
在文件 pthread_cond.c 第 212 行定义.
int pthread_cond_timedwait | ( | pthread_cond_t * | cond, |
pthread_mutex_t * | mutex, | ||
const struct timespec * | absTime | ||
) |
pthread_cond_timedwait
等待条件 在指定的时间之前阻塞,函数会一直阻塞,直到该条件获得信号,或者最后一个参数所指定的时间已过为止。
absTime | 指定的等待时间,单位是操作系统时钟节拍(OS Tick) |
cond | 条件变量句柄,不能为 NULL |
mutex | 指向互斥锁控制块的指针,不能为 NULL |
在文件 pthread_cond.c 第 291 行定义.
int pthread_cond_wait | ( | pthread_cond_t * | cond, |
pthread_mutex_t * | mutex | ||
) |
阻塞方式获取条件变量,阻塞的线程可以通过 pthread_cond_signal() 或 pthread_cond_broadcast() 唤醒
在文件 pthread_cond.c 第 342 行定义.
int pthread_condattr_destroy | ( | pthread_condattr_t * | attr | ) |
销毁条件变量属性对象
在文件 pthread_cond.c 第 101 行定义.
获取条件变量的范围,目前只支持获取PTHREAD_PROCESS_PRIVATE条件变量属性
在文件 pthread_cond.c 第 76 行定义.
int pthread_condattr_init | ( | pthread_condattr_t * | attr | ) |
初始化条件变量属性对象
在文件 pthread_cond.c 第 110 行定义.
设置条件变量的范围
如果 pshared 属性在共享内存中设置为 PTHREAD_PROCESS_SHARED,则其所创建的条件变量可以在多个进程中的线程之间共享。
在文件 pthread_cond.c 第 87 行定义.
STATIC VOID PthreadCondValueModify | ( | pthread_cond_t * | cond | ) |
在文件 pthread_cond.c 第 175 行定义.
在文件 pthread_cond.c 第 234 行定义.
STATIC VOID PthreadCountSub | ( | pthread_cond_t * | cond | ) |