Threading and Concurrency¶
Key Question
How can a single instance of our program perform multiple coordinated tasks at the same time?
Sequential programming, VLIW concept, desire to emulate the real world with parallel threads, freeof-charge exploitation of multiple cores (eight per
mythmachine, eight perricemachine), pros and cons ofthreading versusforking.C++
threads,threadconstruction using function pointers, blocks, functors,join,detach, race conditions,mutex, IA32 implementation oflockandunlock, spin-lock, busy waiting, preemptive versus cooperative multithreading,yield,sleep_for.Condition variables, rendezvous and thread communication,
lock_guard,wait,notify_one,notify_all, deadlock, busy waiting.Semaphore concept and
semaphoreimplementation, generalized counter, pros and cons ofsemaphoreversus exposed condition variables, thread pools, cost of threads versus processes.Active threads, blocked threads, ready thread queue, high-level implementation details of the thread manager,
mutex, andcondition_variable_any.Pure C alternatives via
pthreads, pros ofpthreads over C++ thread package.