Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 458 Bytes

linux_lock.pod

File metadata and controls

16 lines (12 loc) · 458 Bytes

Linux锁机制所遇知识点小结

递归锁

Linux下的锁可以指定是否是循环递归锁, 通过 PTHREAD_MUTEX_RECURSIVE 指定, 如:

Mutex::Mutex()
{
    pthread_mutexattr_t mutexattr;
    pthread_mutexattr_init(&mutexattr);
    pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
    pthread_mutex_init(&m_mutex, &mutexattr);
    pthread_mutexattr_destroy(&mutexattr);
}