advanced Estimated learning time: 12 h

EC-20.3 Passing Work Between Tasks Without Losing It

You can choose between a mutex, a semaphore and a message queue for a given hand-off, explain how priority inversion arises and how inheritance fixes it, and write an interrupt handler that passes data to a task without a race.

Before:EC-11. Data Communications and Computer NetworksEC-16. Ethics, Safety, Sustainability and Standards

Two tasks sharing anything is where real-time systems go wrong, and the failures are the worst kind: rare, timing-dependent and gone by the time anybody looks. The good news is that the number of correct patterns is small. This topic teaches those patterns, the one famous failure that killed a spacecraft mission, and the habit of asking what happens if a switch occurs on this exact line.

Work through these

  • The race condition, and the smallest example that shows one

    Two pieces of code reading and writing the same variable can interleave in an order neither author imagined, and the result is wrong on perhaps one run in ten thousand. Seeing the shortest example that fails is worth more than any amount of general warning.

    NPTEL: Real Time Operating System (IIT Kharagpur) · Course
  • Mutual exclusion, the critical section, and keeping it short

    A lock makes a section of code exclusive, and every moment spent holding one is a moment a higher-priority task may be blocked. The rule that follows is to hold a lock across the shortest possible span and never across anything that waits.

    NPTEL: Real Time Operating System (IIT Kharagpur) · Course
  • Counting semaphores, and signalling from an interrupt to a task

    Signalling is a different problem from exclusion, and using a lock for it is a common and confusing mistake. An interrupt that signals a waiting task is the standard shape for getting work out of a handler quickly.

    NPTEL: Embedded System Design with ARM (IIT Kharagpur) · Course
  • Message queues, and why copying beats sharing a pointer

    Handing over a copy of the data removes every question about who may still be reading it, at the cost of the copy itself. For the small messages typical of embedded work that trade is almost always worth taking.

  • Priority inversion, and priority inheritance as the fix

    A low-priority task holding a lock can block a high-priority one indefinitely while medium-priority work runs, which is how the Mars Pathfinder lander kept resetting. Inheritance raises the holder's priority for the duration and removes the unbounded wait.

    NPTEL: Real-Time Systems (IIT Kharagpur) · Course
  • Deadlock, and the ordering rule that prevents it

    Two tasks each holding what the other needs will wait forever, and no amount of testing reliably finds it. Taking locks in one globally agreed order removes the possibility rather than reducing its probability.

Sign in to keep your progress.

Free resources

Links last checked 4 Sept 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.