线程同步 - 互斥锁

优质
小牛编辑
130浏览
2023-12-01

类型

pthread_mutex_t

互斥锁基本操作

函数描述
[[pthread_mutex_initpthread_mutex_init]]初始化互斥锁
[[pthread_mutex_lockpthread_mutex_lock]]阻塞申请互斥锁
[[pthread_mutex_unlockpthread_mutex_unlock]]释放互斥锁
[[pthread_mutex_trylockpthread_mutex_trylock]]非阻塞申请互斥锁
[[pthread_mutex_destroypthread_mutex_destroy]]销毁互斥锁

互斥锁属性的基本操作

函数描述
[[pthread_mutexattr_initpthread_mutexattr_init]]初始化属性对象
[[pthread_mutexattr_destroypthread_mutexattr_destroy]]销毁属性对象
[[pthread_mutexattr_settypepthread_mutexattr_settype]]设置属性对象的属性
[[pthread_mutexattr_gettypepthread_mutexattr_gettype]]获得属性对象的属性