Search⌘ K

One More Problem: Waiting For Another

Explore the concept of one thread waiting for another in concurrent programming. Understand key concurrency issues like mutual exclusion, critical sections, and race conditions. This lesson introduces how threads synchronize through sleeping and waking mechanisms, setting the foundation for advanced synchronization methods such as condition variables.

We'll cover the following...

This chapter has so far set up the problem of concurrency as if only one type of interaction occurs between threads, that of accessing shared variables and the need to support atomicity for critical sections.

Sleeping/waking a thread

As it turns out, there is another common interaction that arises, where one thread must wait for another to complete some action before it continues. This interaction arises, for example, when a process performs a disk I/O and is put to sleep; when the I/O completes, the process needs to be roused from its slumber so it can continue.

Thus, in the coming chapters, you’ll be not only studying how to build support for synchronization primitives to support atomicity but ...