当前位置:网站首页>Some good articles on pthread multithreading

Some good articles on pthread multithreading

2022-04-23 14:07:00 JokerYourMemory

Read some good articles on Multithreading , For record :

Condition variables, pthread_cond_wait Explanation of classic usage , Other articles still don't make it clear , This article is still very good :

pthread_cond_wait Detailed explanation _zzran The column -CSDN Blog Usually , and pthread _cond_wait Paired with pthread_cond_signal , Also used for pthread_cond_t The initialization of the pthread_cond_init, Destroyed pthread_cond_destroy function , And for lock protection pthread_mutex_lock and pthread_mutex_unlock, Later, we will explain why it is locked .      Initializing condition variables inthttps://blog.csdn.net/zzran/article/details/8830213

pthread_cond_wait Suspend the process instead of blocking , The difference between concepts refers to :

Linux review :pthread Of cond and mutex_ Blog for programming enthusiasts -CSDN Blog The mutex mutex This article describes pthread Creation and separation of , What is the condition variable of the waiting thread ? Sync The concept is mainly when a thread can modify variables , When other threads can also read or modify this variable , You need to synchronize these threads , To ensure that they do not access invalid values when accessing the stored contents of variables . stay Linux in , It can be understood that one thread needs to wait for another thread to complete a condition variable , In order to continue their own , Or hang yourself up . By the way, review the difference between hanging and blocking when multiple control threads ...https://blog.csdn.net/weixin_41143631/article/details/89303723 Baidu's is also very good , At first glance, it is the official translation :

https://baike.baidu.com/item/pthread_cond_wait/3011997?fr=aladdinicon-default.png?t=L892https://baike.baidu.com/item/pthread_cond_wait/3011997?fr=aladdin The feeling of understanding is different from yourself , But after all, it gives the operation and results :

Condition variables, ,pthread_cond_wait() Usage analysis _ A pigsty for non serious graduate students -CSDN Blog Foreword no matter which way to wait , Must be matched with a mutex , To prevent multiple threads from requesting pthread_cond_wait()( or pthread_cond_timedwait(), The same below ) Competitive conditions (Race Condition).mutex Mutex must be a normal lock (PTHREAD_MUTEX_TIMED_NP) Or adapt to the lock (PTHREAD_MUTEX_ADAPTIVE_NP), And calling pthread_cond_wai...https://blog.csdn.net/paulkg12/article/details/84663378

版权声明
本文为[JokerYourMemory]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401090470.html