mtx_lock函数
概要:
#include <threads.h> int mtx_lock(mtx_t *mtx);
描述:
该函数阻塞调用线程,直至加锁参数mtx指向的互斥。如果调用线程已加锁互斥,并且该互斥是非递归互斥,该互斥不应再被调用线程加锁。对于同一互斥,先前mtx_unlock函数调用与该函数的操作同步。
参数:
mtx_t *mtx
指向将被加锁的互斥的指针。
返回值:
如果加锁互斥,函数返回thrd_success;如果不能加锁互斥,函数返回thrd_error。
范例:
|
|
输出:
number: 90000
注:使用Pelles C编译。
相关内容:
mtx_init | 创建互斥的函数。 |
mtx_timedlock | 支持超时加锁互斥的函数。 |
mtx_destroy | 销毁互斥的函数。 |
mtx_trylock | 尝试加锁互斥的函数。 |
mtx_unlock | 解锁互斥的函数。 |