Skip to main content

Synchronization & Concurrency

Source: UC Berkeley CS162, Fall 2020/2021 - Prof. John Kubiatowicz, Lectures 6-9

Concurrency is the art of running many things on one CPU (or many CPUs) and still getting a correct answer. These four pages follow the CS162 arc from the raw mechanism - how one thread is swapped out for another - up through the high-level tools you actually program with: locks, semaphores, monitors, and the classic readers/writers problem.

Each page embeds the original lecture and captures the key slides inline, so you can read the notes and jump to the moment in the video where a diagram is drawn.

#LectureWhat it covers
1Concurrency & Mutual ExclusionThreads and the context switch, the two-stack model, switch(), preemption by interrupts, non-determinism, race conditions, and the first look at locks.
2Semaphores, Locks & Atomic InstructionsSemaphores (P/V), the producer/consumer pattern, implementing locks - first by disabling interrupts, then with hardware atomic instructions like test-and-set.
3Atomic Instructions, Monitors & Readers/WritersFinishing atomic instructions and compare-and-swap, then monitors: locks plus condition variables, Mesa vs Hoare semantics, and the readers/writers problem.
4Monitors, Readers/Writers & Process StructureCompleting readers/writers with monitors, monitor design rules, and how all of this sits inside the structure of a real process.

How to read these pages

Each page uses a small set of labelled cards, and the label tells you what kind of thing is inside before you read a word:

The card vocabulary
  • Facts - named terms with short definitions.
  • Numbers - the constants and timings worth memorising.
  • Decision - a question with a "pick this when" answer, for choosing between primitives.
  • Gotcha - a trap that causes a real, hard-to-find bug.

The slide images are captured directly from the lecture video and are the work of Prof. Kubiatowicz and UC Berkeley; they are reproduced here for study.

0%0 of 6 pages studied