<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/wmthornton-dev">Wayne Thornton</a> created an issue: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5548">#5548</a>
</p>
<p>
Assignee: Wayne Thornton
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 id="user-content-summary" dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">External Dynamic RAM (DRAM) acts as a hidden source of non-determinism. DRAM cells require periodic, hardware-mandated refresh cycles (<span data-math-style="inline" class="js-render-math" style="margin-top: 0;">tREFI</span>) to prevent data loss. During these refresh cycles, the memory controller locks the bank.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">If a high-priority RTEMS control thread (such as flight software hazard avoidance) suffers an L1/L2 cache miss, the CPU must fetch from main memory. If that fetch collides with a <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">tREFI</span> cycle or a row-buffer conflict, the thread is effectively stalled by the hardware. A memory read that normally takes 40ns can spike to over 300ns. While acceptable in standard OS environments, this "tail latency" shatters Worst-Case Execution Time (WCET) bounds in RTEMS. Developers must grossly over-pad their execution deadlines to account for worst-case hardware refresh alignments, wasting CPU cycles.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The Deterministic Hedged Read Library (DHRL) solves hardware latency spikes by trading available memory bus bandwidth and SMP parallel compute for strict time determinism. It leverages the statistical reality that two physically independent memory controllers will not execute refresh cycles simultaneously.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">##Execution Flow:</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Redundant Mapping: Critical read-only payloads are duplicated across two independent physical memory channels (for example, Bank A and Bank B)</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">SMP Thread Pinning: DHRL spawns two worker tasks and uses <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">rtems_task_set_affinity()</span> to rigidly pin them to distinct physical CPU cores.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The Hedged Read ("Race" Condition): When the main application requires data, it fires <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">rtems_event_send()</span> to wake both pinned workers. Both cores simultaneously force an AXI bus read to their respective memory controllers.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Lock-Free Resolution: Whichever memory controller is not currently refreshing returns the data first. That "winning" thread executes a C11 <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">atomic_compare_exchange_strong</span> to claim a shared flag, which instantly wakes the main thread to hand over the pointer. The slower read is safely dropped.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">##Trade-offs & Hardware Requirements</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Cost: DHRL intentionally burns instantaneous memory bus bandwidth and requires dedicating parallel CPU cores to execute a single read operation.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Hardware Dependency: This software-level fix requires a target SoC with an RTEMS SMP BSP and at least two physically independent memory controllers.It provides zero benefit on single-channel architectures.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Benefit: Absolute bounds on memory fetch latency and "free" spatial fault tolerance against Single Event Functional Interrupts (SEFIs) on the memory controllers.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">##Acceptance Criteria
[ ] <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">dhrl_init()</span> correctly spawns and pins worker threads using the RTEMS Classic API.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">[ ] <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">dhrl_fetch_data()</span> correctly wakes workers, executes the race, and returns the valid pointer via C11 Atomics and RTEMS Event Sets without deadlocking.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">[ ] API successfully handles arbitrary memory pointers (volatile void*).</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">[ ] Validation: Empirical tests on multi-channel hardware (or cycle-accurate simulators) demonstrate a mathematically bounded WCET for DRAM fetches, eliminating the tail latency distribution curve.</p>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">[ ] Library compiles cleanly via <span data-math-style="inline" class="js-render-math" style="margin-top: 0;">waf</span> and integrates into the <span data-math-style="inline" class="js-render-math">cpukit</span> build structure gated by compiler flags.</p>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5548">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/3-3kvpijfvbwwrkn1ilcm0h6blu/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5548 at 1775669914
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5548"}}</script>
</p>
</div>
</body>
</html>