49 return (hand ==
nullptr) ? 1 : 0;
96 const uint32_t f = *hand;
104 .state_base_bytes =
sizeof(uint32_t),
105 .state_frame_bytes = 0U,
108 .on_access =
nullptr,
109 .on_insert =
nullptr,
124typedef enum : uint64_t {
136typedef enum : uint8_t {
171 return (s ==
nullptr) ? 1 : 0;
224 return (uint32_t)(x % (uint64_t)c->
capacity);
229 .state_base_bytes =
sizeof(uint64_t),
230 .state_frame_bytes = 0U,
233 .on_access =
nullptr,
234 .on_insert =
nullptr,
273 const size_t required =
sizeof(
cb_lru_t) + ((
size_t)c->
capacity * 2U *
sizeof(int32_t));
278 l->
prev = (int32_t*)&l[1];
327 if (l->
prev[f] != -1) {
329 }
else if (l->
head == f) {
332 if (l->
next[f] != -1) {
334 }
else if (l->
tail == f) {
443 const int32_t f = l->
tail;
451 .state_base_bytes =
sizeof(
cb_lru_t),
452 .state_frame_bytes = 2U *
sizeof(int32_t),
488 return (hand ==
nullptr) ? 1 : 0;
561 const uint32_t f = *hand;
575 .state_base_bytes =
sizeof(uint32_t),
576 .state_frame_bytes = 0U,
Eviction-policy comparison harness for the #147 memory-hierarchy decision record: the DIP seam every ...
const cache_policy_t *const g_cb_policies[]
The registered policy table (defined in src/policies.c).
const cache_policy_t g_cb_policy_srrip
SRRIP: the 2-bit re-reference-interval candidate (src/policy_scanresist.c).
const cache_policy_t g_cb_policy_slru
Segmented-LRU: the scan-resistant candidate (src/policy_scanresist.c).
const uint32_t g_cb_policy_count
Number of entries in g_cb_policies.
static void internal_lru_to_head(cb_lru_t *l, int32_t f)
Splice frame f to the MRU (most-recently-used) head.
static uint32_t internal_lru_victim(cb_cache_t *c, uint32_t *scanned)
Choose the LRU victim: the frame at the list tail.
static void internal_lru_unlink(cb_lru_t *l, int32_t f)
Unlink frame f from the recency list.
static const cache_policy_t s_cb_policy_random
static int internal_fifo_init(cb_cache_t *c)
Bind FIFO state: a single round-robin hand over the frame ring.
static uint32_t internal_clock_victim(cb_cache_t *c, uint32_t *scanned)
Choose the CLOCK victim by second-chance sweep.
static void internal_rand_deinit(cb_cache_t *c)
Release Random-policy state (the PRNG seed).
static uint32_t internal_rand_victim(cb_cache_t *c, uint32_t *scanned)
Choose a uniformly random victim frame.
static int internal_lru_init(cb_cache_t *c)
Bind true-LRU state: a doubly-linked recency list over frames.
static const cache_policy_t s_cb_policy_clock
static void internal_fifo_deinit(cb_cache_t *c)
Release FIFO state (the insertion hand).
static const cache_policy_t s_cb_policy_fifo
cb_rand_shift_t
xorshift64 shift-amount triple used in the Random policy's PRNG step.
@ k_rand_shift_b
Second xorshift64 shift.
@ k_rand_shift_c
Third xorshift64 shift.
@ k_rand_shift_a
First xorshift64 shift.
static void internal_clock_set(cb_cache_t *c, uint32_t frame)
CLOCK reference hook: set frame's reference bit.
static const cache_policy_t s_cb_policy_lru
cb_rand_seed_t
Initial PRNG seed for the Random eviction policy.
@ k_rand_seed
Reproducible non-zero xorshift seed.
static void internal_clock_deinit(cb_cache_t *c)
Release CLOCK state (the sweep hand).
static void internal_lru_touch(cb_cache_t *c, uint32_t frame)
LRU hit hook: move the just-accessed frame to the MRU head.
static void internal_lru_deinit(cb_cache_t *c)
Release true-LRU state (control block + index arrays).
static void internal_lru_insert(cb_cache_t *c, uint32_t frame)
LRU insert hook: place a freshly-loaded frame at the MRU head.
static int internal_clock_init(cb_cache_t *c)
Bind CLOCK state: one reference bit per frame + a sweep hand.
static uint32_t internal_fifo_victim(cb_cache_t *c, uint32_t *scanned)
Choose the FIFO victim: the frame the hand currently points at.
static int internal_rand_init(cb_cache_t *c)
Bind Random-policy state: a deterministic xorshift64 seed.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
The replacement-policy DIP seam (the eventual firmware Layer-2 seam).
The fixed-capacity frame cache a policy manages.
cb_frame_t * frames
capacity frame slots.
size_t policy_workspace_bytes
Bytes available at the storage.
void * policy_data
Policy-private state (rings, stacks, sketch).
uint32_t capacity
Number of frame slots (the RAM budget knob).
void * policy_workspace
Caller-provided policy-state storage.
uint8_t meta[16]
Per-policy scratch (ref bits, RRPV, list links).
LRU recency list threaded through prev/next frame-index arrays.
int32_t head
Most-recently-used frame, or -1.
int32_t * next
next[f] – frame nearer LRU, or -1.
int32_t tail
Least-recently-used frame (the victim).
int32_t * prev
prev[f] – frame nearer MRU, or -1.