Section 7.2 Exam 2
General topics: Chapters 26 through 32 (excluding 29).
-
Describe the similarities and differences of threads and processes. What do threads share with each other, what is different? Include at a minimum questions of memory usage, open files, registers, TLBs.
-
Given a simple piece of code, demonstrate trace of how if that code is executed by two different threads inconsistencies arise (e.g. losing track of cases when counting), or the output may vary depending on ordering (e.g. printouts happening in varying orders).
-
Be able to define and provide examples of key concurrency terms like critical section, race condition, mutual exclusion, atomic operations.
-
Be familiar with the core semantics of the thread api, namely the
createandjoinmethods. For example, when will a thread created bycreatestart executing? Which thread doesjoinwait for? What happens if that thread has completed beforejoinis called? -
Describe the main mechanism provided by (spin) locks, and provide examples where locks are used to protect some shared data.
-
Describe what deadlock is, how it can occur, and different mechanisms for preventing it from completely locking the system up.
-
Describe hardware operations that can be used to implement (spin) locks and provide corresponding implementations of the lock interface using such an operation (in particular
test-and-set). -
Describe how condition variables work, what they are used for, and how their interface looks like (what methods are used etc). Include a discussion of why there is always an associated spin lock and what happens when a thread goes to sleep using a condition variable.
-
Discuss the tradeoffs between
signalwaking up a single sleeping thread andbroadcastwaking up all sleeping threads. When might each be appropriate? -
Discuss the bounded buffer problem and how it is solved using 2 condition variables (and why we need 2 variables).
-
Define the semantics and API of a
semaphore. -
Show how we can implement a lock using a semaphore, and how we can implement ordering of events using a semaphore.
-
Describe how to solve the bounded buffer problem (with a buffer of size more than 1) using semaphores.
-
Describe the problem solved by the so-called "reader-writer locks". Detail how the two locks on it are used. Explain why normal locks, that are usually required to be unlocked by the same thread that locked them, are not sufficient to solve this problem.
You have attempted of activities on this page.
