Conditional Wait Variables

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Your videos are really useful. Thank you so much, my professors doesn't seem to know how to explain it and you do so in less than 2 minutes

alvarorogerzapata
Автор

If Thread B hits the cond_wait before thread A locks the mutex, doesn't this deadlock? Thread B holds the lock and doesn't release it until cond_wait is signaled which only happens after thread A acquires a lock which is impossible because thread B is holding the lock.

EDIT: Nevermind, realized cond_wait has two arguments and synchronizes with the lock to ensure this doesn't happen.

MartinCharles
Автор

"is_done=1" for Thread-A should come before mutex_lock(). Here, once Thread-A gets mutex lock then we are setting is_done . if we already got lock then why do we need to set it at all. Please let me know if i am missing something.

NarendraPalSingh_India
Автор

There is a convention that uses while instead of if to check the condition for whether to actually wait. Why is it?

HengZhong-jq