linux 内核中的pthread_mutex_lock
和pthread_cond_wait
是什么等价物。以及如何使用它们。您能否提供简单的(hello world)示例。
最佳答案
- 对于互斥量(如 Als 所说):
mutex_lock()
和 mutex_unlock()
我们应该在使用 mutex_init()
之前初始化互斥锁(来自 #include <linux/mutex.h>
)
- 相当于
pthread_cond_wait
wait_event_interruptible()
和 wake_up_interruptible()
我们应该用 init_waitqueue_head()
初始化 wait_queue_head (来自 #include <linux/wait.h>
)
关于c - linux 内核中 pthread_mutex_lock 和 pthread_cond_wait 的等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10104799/