Tech●●●●●Difficulty 5 of 5

How did a low-priority task freeze a spacecraft on Mars?

Days after Mars Pathfinder landed, its computer kept rebooting. The cause was a humble background job that blocked the most important one.

▶ Start the story

A low-priority task froze a spacecraft on Mars because it held something an important task needed, while busier medium-priority tasks kept the low-priority one from finishing. This is called priority inversion, and it happened to Mars Pathfinder, which landed on 4 July 1997.

Priority inversion is a scenario in which a high-priority task is indirectly held up by a lower-priority one, so that the priorities are effectively turned upside down. Here is how. Call the important task H and a humble one L. If H needs a resource that L has already taken, H must wait until L lets go. Normally that is short. But a third task, M, of medium priority, can then preempt L, since M does not need the resource. L cannot finish and release it, so H, the most important task, cannot run.

How priority inversion works
  1. Step 1: L holds a resource

    A low-priority task takes the

  2. Step 2: H must wait

    The high-priority task needs it and is blocked

  3. Step 3: M L

    A medium task runs instead, so L cannot finish

  4. Step 4: Deadline missed

    H, the most important task, never gets to run

On Mars the same thing happened. A much lower-priority weather-instrument task held a , and several medium-priority tasks preempted it. The high-priority data-handling task then blocked waiting for that resource and missed its deadline. The spacecraft is designed to react to a missed deadline by resetting its computer, and so it did. A lost no data already collected, but the rest of that day's activities waited until the next day.

The fix was one small setting, : a low-priority task holding a resource temporarily takes the priority of the highest-priority task waiting for it. Engineers sent a patch to Mars on 21 July.

Quiz me

0/3

  1. 1.What is priority inversion?
  2. 2.Why did medium-priority tasks make Pathfinder's problem worse?
  3. 3.How was the problem fixed?

Recap

Priority inheritance fixes inversion: the task holding the lock borrows the priority of the one waiting.

💡 A trick to remember it · A big kid stuck behind a tiny kid tying a shoe while medium kids keep cutting in: let the tiny kid borrow the big kid's place.

Surprising fact · Pathfinder's engineers had seen the bug before launch but ranked it low priority.

Sources (4)

No source, no claim. Every fact in this lesson (17 claims) cites at least one of these.

  1. [1]Mars Pathfinder · Wikipedia
  2. [2]Real-time operating system · Wikipedia
  3. [3]Priority inversion · Wikipedia
  4. [4]What really happened on Mars? Authoritative account by Glenn Reeves (1997) · Glenn E. Reeves, Mars Pathfinder software lead, NASA JPL (hosted by UNC)
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗