05 — Architecture

Keeping the dangerous part small.

+ The questionHow does the way software is divided into parts change what must be proven about each?

A timer that does not trust the program

A watchdog is a timer, often a separate circuit, that the software must reset at regular intervals. If the program hangs, stuck in a loop or waiting for something that never arrives, it stops resetting the timer, the timer runs out, and the watchdog forces the device into a safe state: it stops a motor, raises an alarm or restarts the processor. The FDA finalized its guidance on infusion pumps in 2014. In that guidance, the FDA asks makers to describe their watchdog timer, lists watchdog tests among the safety mechanisms a pump should have, and lists a watchdog failure among the hardware causes of system failure.

The watchdog shows the main idea of software architecture for safety: a function that must not fail is protected by something that does not share its weaknesses. The watchdog does not run the dose calculation and does not need to understand it. It needs only to be reset at regular intervals, which shows that the program is still running, and its own logic is small enough to verify thoroughly. A maker's safety case is its argument, backed by evidence, that the device is safe. The same guidance adds a caution that applies to every safety mechanism: the safety case must also cover the hazards that the mechanism itself could create. One such hazard would be a watchdog that resets a pump in the middle of an infusion.

A program that runs on time can still be wrong

A program that runs normally while computing a wrong dose keeps resetting its watchdog on time, so the watchdog never acts. Protection against a wrong output needs a different mechanism: an independent check of the result, a limit enforced outside the software, or a second calculation by different means. Naming which failures each safety mechanism detects, and which it cannot detect, is part of the design.

09 — What a watchdog can and cannot see
A HANG software resets the timer program hangs timeout watchdog timer safe state: motor stopped, alarm A WRONG ANSWER timeout watchdog timer computed dose wrong watchdog never acts needs an independent check of the result TIME schematic
CodeFaultReadoutFocal detail
Plate 09 — A watchdog forces a safe state when software stops responding, but a program that runs on time while computing the wrong answer keeps resetting it. Each safety mechanism catches some failures and is blind to others, and the design has to say which.

Items, units and boundaries

IEC 62304 describes a program as a software system made up of software items, which are any identifiable parts of it. Items are divided in turn into smaller items, down to software units (Chapter 4). The division is not a filing scheme. It determines whether a fault in one part can affect another. If one item can overwrite another's memory, use up the processor time the other needs, or hand it corrupted data without detection, a fault in the first item can make the second fail, and both must be treated as one.

The standard calls the remedy segregation: any mechanism that prevents one software item from negatively affecting another. Segregation can be physical, with the critical function on its own processor; it can use the memory protection of an operating system, so that one process cannot write into another's memory; or it can rest on checks at the boundary, so that data crossing the boundary is validated. Each mechanism has to be shown to work, because a claimed boundary that a fault can cross is worse than none: it lowers the rigor applied to the code outside the protected part without lowering the risk.

Segregation is what lets the class of Chapter 4 apply to parts of a program rather than to the whole. If the items that could contribute to serious harm are separated from the rest, only those items need the class C activities, and the user interface, the logging and the reporting code can be developed at class B or A. An architecture is therefore a decision about how much evidence each part of the program needs, as much as a decision about its structure.

Solved example: what segregation buys

Suppose a pump's software has 200,000 lines. The dose calculation and the delivery control are the only parts whose failure could cause death or serious injury, and together they take 8,000 of those lines. Without demonstrated segregation, the whole program is class C, and the detailed design and stricter unit-verification criteria of that class apply to all 200,000 lines. Now suppose the 8,000 lines run on a separate processor that the rest of the program cannot write to, and every command crossing the boundary is checked against the prescription. The class C work then applies to 8,000 lines, 4 percent of the program. The remaining 96 percent still needs its own class, its own tests and evidence that the boundary holds.

10 — Segregation puts the strictest work where it matters
SOFTWARE SYSTEM: 200,000 LINES logging and reports CLASS A network communications CLASS B user interface CLASS B operating system and libraries (SOUP) PER ITS ROLE SEPARATE PROCESSOR dose calculation and delivery control: 8,000 lines CLASS C CHECK boundary: separate processor; every command checked against the prescription the boundary must be shown to hold class C work: 8,000 of 200,000 lines = 4%
SpecificationCodeReadoutFocal detail
Plate 10 — If the code that could cause serious harm is separated by a boundary shown to hold, only that code needs class C rigor. Here segregation confines the strictest work to 8,000 of 200,000 lines, while the rest keeps the class and tests that fit its own risk.

Where the parts live

The architecture also has to say where each part runs and what it depends on. Much of the code in a modern device was written by someone else: the operating system, the network stack, a database, a library that reads images, a cloud service. Each of these is an item the maker did not write and cannot fully inspect. For each one, the architecture has to say where it runs, limit what it can affect, and state what the device does when it misbehaves. Chapter 6 is about those items.

IDx-DR's public record lists three software items, each with its own version number: the client on the camera's computer, a service on the server that passes images and results between the client and the analysis, and the analysis that grades the images. In June 2021 the FDA cleared a 510(k) for an update that moved the client to version 3.2.0, the analysis to 2.1.1 and the service to 1.1.2. The next update, cleared in June 2022, moved them to 3.5.0, 2.3.0 and 1.2.0.

Because the parts are separate, a maker can change one and argue, with evidence, that the others are untouched. The split also changes what can go wrong. An analysis that runs on a server depends on the network, and the 2021 version added messages that tell an operator whether a submission was lost or is simply not ready yet.

Chapter 21 returns to the 2022 change. That change replaced one model inside the analysis, the classifier that judges image quality, and it changed which patients received an answer. A maker can confine a change to one item, but the architecture does not guarantee that the change's effects stay inside that item. Every change therefore needs regression tests at the level of the whole system.

Draw the architecture with its classes and boundaries

Draw every software item, including those from third parties, with its safety class, where it runs, and the mechanism that separates it from its neighbors. For each boundary that lowers a class, record the evidence that the mechanism works, such as memory-protection settings or the separate processor, and include a test that tries to break it. For each safety mechanism, record which failures it detects, which it cannot, and what hazards it could create itself.

+ What this chapter established
  • A watchdog shows the core idea: protect a critical function with a mechanism that does not share its weaknesses.
  • IEC 62304 divides software into items and units; segregation is any mechanism that stops one item from harming another.
  • Demonstrated segregation lets the strictest class apply only to the code that could cause serious harm, not to the whole program.
  • IDx-DR's three items carry their own version numbers, so each update records which items changed; a change made inside one item, such as the 2022 image-quality classifier, still needs regression tests of the whole system.
Created with Claude (Anthropic).
Educational reference material, not engineering, regulatory or clinical advice. Product and company names referenced are the property of their respective owners.