Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 是否有一个pthreadsapi来标识互斥锁所有者的句柄?_C_Pthreads_Mutex - Fatal编程技术网

C 是否有一个pthreadsapi来标识互斥锁所有者的句柄?

C 是否有一个pthreadsapi来标识互斥锁所有者的句柄?,c,pthreads,mutex,C,Pthreads,Mutex,是否有一个pthreadsapi来标识互斥锁所有者的句柄?我宁愿使用pthreadapi,而不是在pthreadapi上构建自己的结构和锁定/解锁API。我使用的是pthreads库的C实现。我不知道有任何用于此的API,但是,它可以很容易地完成。 您需要做的是创建一个全局变量,该变量将保存保存互斥对象的pthread句柄。 每次线程锁定互斥锁时,它都会将此变量(当互斥锁被锁定时)设置为pthread\u self() 这样,如果一个互斥锁被锁定,您可以很容易地查看全局变量,看看是谁锁定了它。我

是否有一个pthreadsapi来标识互斥锁所有者的句柄?我宁愿使用pthreadapi,而不是在pthreadapi上构建自己的结构和锁定/解锁API。我使用的是pthreads库的C实现。

我不知道有任何用于此的API,但是,它可以很容易地完成。 您需要做的是创建一个全局变量,该变量将保存保存互斥对象的pthread句柄。 每次线程锁定互斥锁时,它都会将此变量(当互斥锁被锁定时)设置为
pthread\u self()


这样,如果一个互斥锁被锁定,您可以很容易地查看全局变量,看看是谁锁定了它。

我知道这个解决方案。我希望尽可能多地利用ptheads API。这就是为什么我要求提供这个特定服务的pthreadsapi。谢谢