Concurrency and shared state 00:00:01 One slot and two clocks Seven of eight GPU permits are already in use at the photo desk, so only one slot remains free for new thumbnail jobs. Caller A checks the permit count and sees one available, but pauses right after reading that value. Before A writes its decision, the scheduler runs caller B, which also sees one free permit. A read tells an observer what was true at a particular instant. It grants neither caller the right to start. That missing distinction is why two locally sensible decisions can exceed a shared limit. 00:00:34 Overlap is not parallel execution During a wait for data, the scheduler can let the other job perform useful CPU work. On a single processor those instructions alternate even though both jobs remain in progress. Move the jobs onto separate available devices and some instructions can execute simultaneously. That is parallel execution; merely having two requests in progress did not establish that the hardware was doing both at once. The key is that both jobs accessed the same permit count, so their updates must be coordinated. Concurrency describes work whose lifetimes overlap. Parallelism describes work executing simultaneously. A single processor switching between tasks can expose the same read–decide–write race as two machines executing side by side. 00:01:22 Two local decisions cost one extra slot Both callers independently read that one permit was free, so each believes it can proceed. Each caller now makes its own decision to start work, unaware the other is doing the same. Now nine jobs are trying to use eight physical slots, so one must wait or fail. The disputed count is the number of jobs admitted by the software. The hardware still has only eight slots. Excess work can queue, fail or compete; it cannot create an extra physical machine. 00:01:52 Make admission one operation To prevent this, the system uses an atomic acquire to make the admission decision indivisible. With one permit left, suppose A completes the atomic acquire first. B must wait, time out or decline the work. The outcome is determined by the shared admission operation. Only when the work stops does the permit get released, ensuring active jobs never exceed eight. The atomic operation has to encompass all callers sharing these eight devices. Five independent processes with their own counters could each enforce a local rule while violating the physical pool’s total. 00:02:27 Prove the schedule rather than the timing A test can deliberately hold both callers after their initial reads. Releasing them together makes the vulnerable schedule reproducible instead of depending on thread timing. Run that schedule against the repaired admission path, record every grant and release, and check that the observed active count never passes eight. Passing this one test does not prove every possible schedule correct. The atomic transition and the resource-ownership boundary explain why the limit holds; the test verifies that real callers use it. Also interrupt a job after admission and verify its capacity is returned once the work stops. This tests both halves of the guarantee: no extra admission, and no lost permit after failure.