39 lines
1.4 KiB
C
39 lines
1.4 KiB
C
|
|
#include "free_publish_box.h"
|
||
|
|
#include "hakmem_tiny.h"
|
||
|
|
#include "tiny_route.h"
|
||
|
|
|
||
|
|
// Provide slab entry encode/decode used by Ready ring (match main TU)
|
||
|
|
#ifndef SUPERSLAB_SIZE_MIN
|
||
|
|
#define SUPERSLAB_SIZE_MIN (1u<<20)
|
||
|
|
#endif
|
||
|
|
static inline uintptr_t slab_entry_make(SuperSlab* ss, int slab_idx) {
|
||
|
|
return ((uintptr_t)ss) | ((uintptr_t)slab_idx & 0x3Fu);
|
||
|
|
}
|
||
|
|
static inline SuperSlab* slab_entry_ss(uintptr_t ent) {
|
||
|
|
return (SuperSlab*)(ent & ~((uintptr_t)SUPERSLAB_SIZE_MIN - 1u));
|
||
|
|
}
|
||
|
|
static inline int slab_entry_idx(uintptr_t ent) {
|
||
|
|
return (int)(ent & 0x3Fu);
|
||
|
|
}
|
||
|
|
|
||
|
|
#include "tiny_ready.h"
|
||
|
|
#include "box/mailbox_box.h"
|
||
|
|
|
||
|
|
// Box boundary: minimal checks; callers ensure class_idx/slab_idx are valid
|
||
|
|
void tiny_free_publish_first_free(int class_idx, SuperSlab* ss, int slab_idx) {
|
||
|
|
if (!(ss && ss->magic == SUPERSLAB_MAGIC)) return;
|
||
|
|
if (slab_idx < 0 || slab_idx >= ss_slabs_capacity(ss)) return;
|
||
|
|
tiny_ready_push(class_idx, ss, slab_idx);
|
||
|
|
ss_partial_publish(class_idx, ss);
|
||
|
|
mailbox_box_publish(class_idx, ss, slab_idx);
|
||
|
|
}
|
||
|
|
|
||
|
|
void tiny_free_publish_remote_transition(int class_idx, SuperSlab* ss, int slab_idx) {
|
||
|
|
if (!(ss && ss->magic == SUPERSLAB_MAGIC)) return;
|
||
|
|
if (slab_idx < 0 || slab_idx >= ss_slabs_capacity(ss)) return;
|
||
|
|
// For remote transition, ready hint first to surface candidate to adopters
|
||
|
|
tiny_ready_push(class_idx, ss, slab_idx);
|
||
|
|
ss_partial_publish(class_idx, ss);
|
||
|
|
mailbox_box_publish(class_idx, ss, slab_idx);
|
||
|
|
}
|