DSA Factory
All free lessons
Operating systems

Free Synchronization lessons

8 lessons, about 2 hours in all. Each teaches one idea with a visual, then gives you a problem or a few questions on it. Read the lessons here, then create a free account to practise and keep your progress.

Stage 0The problem: sharing data

  1. Race conditionsSee how two threads incrementing one counter can lose an update, and why it only happens sometimes.13 min
  2. The critical-section problemDefine what a correct solution must guarantee, and see Peterson's classic software solution.14 min

Stage 1Locks and semaphores

  1. Locks and atomic instructionsSee how a mutex fixes the counter, how hardware makes a lock possible, and when spinning beats sleeping.13 min
  2. SemaphoresUnderstand the counter-with-a-queue that can guard a resource pool and also order events between threads.13 min

Stage 2The classic problems

  1. Producer and consumerSolve the bounded-buffer problem with semaphores, and see how one wrong ordering causes deadlock.14 min
  2. Readers and writersAllow many readers or one writer, and see how a simple preference rule can starve the other side.12 min
  3. The dining philosophersSee how each philosopher grabbing a fork can freeze everyone, and the standard ways to prevent it.13 min
  4. Monitors and condition variablesSee how a monitor bundles the lock with the data, and why a condition wait belongs in a while loop.13 min

All of Synchronization is free

That’s the whole topic, from the first idea to the mastery stage, with no card needed. Create a free account to practise, keep your progress and carry on to the next topic.

Create your free account