Section 21.16

FLEX: indirection tables and publication of a new execution view

Full name: Flexible Linked EXecution; the capitals E and X of EXecution supply the last two letters of the name.

What it is

FLEX is a hotpatching §14.33 technique for real-time embedded systems, devices whose work must meet time limits: a way to replace parts of running firmware without a reboot. Heeseung Son, BeomSeok Kim, Ben Lee and Jinsung Cho published it in the IEEE Transactions on Dependable and Secure Computing in March 2026. FLEX makes every function call and every access to a global variable go through a table generated at compile time, the Control Flow Table (CFT). An update switches one pointer from the old table to a new one.

Basis of this account

This account rests only on the abstract and bibliographic record of the article “FLEX: Flexible Linked EXecution for Real-Time Embedded Hotpatching”, IEEE Transactions on Dependable and Secure Computing, volume 23, issue 2, pages 4221 to 4235, March 2026 (https://doi.org/10.1109/TDSC.2025.3644390), as shown in the research repository of Kyung Hee University (https://khu.elsevierpure.com/en/publications/flex-flexible-linked-execution-for-real-time-embedded-hotpatching/). The article’s text was not read. Every statement below about FLEX itself comes from the abstract; the rest is general background and is marked as such. Nothing was run.

What the paper claims

The abstract makes these claims; quotation marks mark the authors’ words.

How it works

The abstract describes FLEX only at the level above. The general technique it names, indirection through a table, works as follows; the layout of FLEX’s own table and its update protocol are not in the abstract.

This pattern is immutable publication §9.24: build the new object where no reader can reach it, then make it visible with one atomic store, and never change it afterwards. The writes that fill the new table must become visible before the pointer does. On a processor or compiler that may reorder memory accesses, that is, without sequential consistency §9.12, this needs a memory barrier §4.37 or a store with release semantics paired with loads that acquire (acquire-release ordering §9.11); otherwise a reader can see the new pointer together with old slot contents.

Execute in place matters because code that runs from flash memory cannot simply be overwritten while it runs: flash memory is erased in pages and written slowly, and on many microcontrollers the processor stalls while the flash memory it runs from is being erased or written. A design that writes new code only into free flash memory and then switches a pointer never rewrites code in use. The old table and the old function bodies can be erased or reused only after no execution can still reach them, the condition that read-copy update §9.20 (RCU) calls the end of a grace period §9.21.

Relaxed consistency, as the abstract names it, means that program state is not converted all at once at the swap; state migrates gradually after the new table becomes active. The abstract does not state the consistency rule, so this account cannot say which mixtures of old and new state FLEX allows.

Worked example

This example is invented and uses the general technique, not FLEX’s actual table format. A 32-bit microcontroller runs a program with 120 functions and 40 global variables, so a table has 120+40=160120 + 40 = 160 slots of 4 bytes, which is 160×4=640160 \times 4 = 640 bytes; the two tables take 2×640=12802 \times 640 = 1280 bytes of memory. Version 2 changes two functions: encode now writes a timestamp in microseconds instead of milliseconds, and decode now reads microseconds.

  1. The update writes the new encode and decode into free flash memory, copies the active table A into table B, changes the two slots in B, and with one 4-byte store makes the active pointer name B. Every lookup that starts after the store uses B.

  2. A task was in the middle of a message when the store happened. Before the store it had called encode through table A, 100 milliseconds after the device started, so its buffer holds the timestamp 100, in milliseconds. Its next call, to decode, reads the pointer again and goes through B. The new decode reads 100 as 100 microseconds, a value 1000 times too small. Each lookup was atomic; the message as a whole mixed two versions.

  3. A low-priority interrupt handler §6.12 that was itself interrupted while inside the old encode is still executing old code. Table A and the old function bodies must stay intact until no execution can still reach them; only then may their flash memory or RAM be reused.

Two repairs exist. The task can load the table pointer once at the start of each message and use that copy throughout, so a whole message runs on one version. Or the update can wait for a quiescent point §14.34, at which no message is in progress. Either way, the property that is needed, one version per message, is stated and enforced separately from the pointer store.

What this account does not establish

Only the abstract was read. This account cannot say how FLEX lays out its table, how and when tasks and interrupt handlers pick up the new table, how state migration works, how an old table is retired, what happens if power fails during an update, or how a device checks who sent a patch.

The abstract’s numbers, about 11% average execution overhead and roughly 17% more flash memory, come here without their benchmark, device or baseline, so they cannot be compared with other systems from this account.

Relaxed consistency means that state is not migrated atomically with the swap. Whatever guarantee FLEX gives about mixed old and new state is in the article, not in this account.

In general, indirection has a cost and a risk. A lookup must obtain the selected address. The instructions it adds depend on the generated code, including whether the processor already holds that address in a register. Changing the active pointer can redirect lookups throughout the table. Changing one slot redirects lookups through that slot.

The bounded pause in the abstract concerns applying an update. The abstract does not show that every deadline of every task is met during the whole update, including the flash writes before the swap.

Questions answered

Does an atomic table-pointer swap make the whole update atomic?

An atomic table-pointer swap does not make the whole update atomic; it makes one step atomic, the moment from which new lookups use the new table. The store is the linearization point §8.6 of publishing the table, not of the update. Every lookup that reads the pointer after the store sees the complete new table, and every lookup before it sees the complete old table, provided the new table was fully written, and those writes made visible, before the store. The rest of the update lies outside that store:

To call an update atomic, first state which abstract operation is atomic, for example that every message is processed entirely by one version. Then give the protocol that enforces it: each operation reads the pointer once, or the swap waits for a quiescent point, together with state conversion and delayed retirement of the old code.

Related entries: Quiescent point (§14.34), Sequential consistency (§9.12), Linearization point (§8.6), Immutable publication (§9.24), Read-copy update (RCU) (§9.20), Grace period (§9.21), Atomic operation (§9.8), Acquire-release ordering (§9.11), Dynamic patching and hot update (§14.33), Dispatch table (§2.39), Quiescent state for a live update (§19.5.1), Live state transfer and representation invariants (§19.5.2), Instruction-cache coherence and executable-code publication (§19.5.3), ConceptOS: component updates and state continuity (§21.15). Further reading: [23, 220].