Week 30
CST-334 Week 6 This is our sixth week in CST-334, also known as Operating Systems. Operating Systems: Three Easy Pieces This week we read chapters 30-32 of our textbook. Chapter 30: Condition Variables Chapter 30 discusses condition variables. Key Takeaways: Threads can use condition variables to check if a condition is true before executing. Condition variables are queues that threads can wait on. Waiting threads can then be woken when the condition variable changes. The function pthread_cond_wait(cond, mutex) adds a thread to the queue, releases the lock, and puts it to sleep. Cond is the condition variable. Mutex is the lock. The function pthread_cond_signal(cond) wakes the next thread in the queue and gives it the lock. Cond is the condition variable. You should use while loops instead of if statements when checking a condition variable. Chapter 31: Semaphores Chapter 31 discusses semaphores. Key Takeaways: A semaphore is an object that contains a...