linux 线程
2021-03-06, updated 2021-09-12
pthread 相关函数
pthread_sigmask
用作在主调线程里控制信号掩码。
|
|
参数
- SIG_BLOCK: 结果集是当前集合参数集的并集(把参数set中的信号添加到信号屏蔽字中)
- SIG_UNBLOCK: 结果集是当前集合参数集的差集(把信号屏蔽字设置为参数set中的信号)
- SIG_SETMASK: 结果集是由参数集指向的集(从信号屏蔽字中删除参数set中的信号)
返回值
- 成功:0
- 失败:error number
pthread_detach()
pthread_detach - detach a thread
分离子线程,线程运行结束时自动回收资源
|
|
return value: On success, pthread_detach() returns 0; on error, it returns an error number.
pthread_self
pthread_self - obtain ID of the calling thread
|
|
Compile and link with -pthread.
return value
This function always succeeds, returning the calling thread’s ID.
pthread_mutex
|
|
pthread遇到的问题
调用pthread_cancel函数请求后,等到响应请求时,代码调用了pthread_clean_push函数中的clean_fun1和clean_fun2,函数clean_fun2中的语句先被打印。