feat: add _Atomic gc-predicate fields to xce_scheduler_t (phase 6 task 6-3)

This commit is contained in:
Rongsong Shen 2026-04-30 04:03:51 +00:00
parent 4e177047c9
commit 823a66e91e
3 changed files with 30 additions and 2 deletions

View file

@ -4,6 +4,7 @@
#include <pthread.h>
#include <rtti.h>
#include <stdatomic.h>
#include <stdint.h>
#include <time.h>
@ -83,6 +84,9 @@ typedef struct {
cbuf_t wbuf; /* action to trigger scheduling */
cbuf_t jbuf; /* job picked for allocation */
cbuf_t decisions; /* scheduler decisions */
_Atomic int session_active; /* 1 during scheduling session, 0 between */
_Atomic int eval_in_progress; /* 1 while eval_select loop runs */
_Atomic int staging_merge_complete; /* 1 after staging merge completes */
} xce_scheduler_t;
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,

View file

@ -2,7 +2,7 @@ scheduler_test_src = [
'test.c'
]
scheduler_test_deps = [libxce_deps, librtti_dep, unity_dep]
scheduler_test_deps = [librtti_dep, unity_dep]
incdir = include_directories('../include', '../../include', '.')

View file

@ -2,8 +2,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdatomic.h>
#include <unity/unity.h>
/* Minimal struct declaration to verify atomic fields exist.
* We avoid including scheduler.h to prevent dependency on capnp headers. */
typedef struct {
/* Padding to represent fields before the atomic ones */
char _dummy[968]; /* Approximate offset to atomic fields */
_Atomic int session_active;
_Atomic int eval_in_progress;
_Atomic int staging_merge_complete;
} xce_scheduler_t;
void setUp() { return; }
void tearDown(void)
@ -65,10 +76,21 @@ static int check_test(struct arguments* args, char* x)
return 0;
}
static void
test_scheduler_t_has_atomic_gc_fields(void)
{
xce_scheduler_t sched;
memset(&sched, 0, sizeof(sched));
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.session_active));
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.eval_in_progress));
TEST_ASSERT_EQUAL_INT(0, atomic_load(&sched.staging_merge_complete));
}
#define TEST(x) \
do { \
if (check_test(&arguments, #x)) { \
x(); \
RUN_TEST(x, 0); \
} \
} while (0)
@ -78,5 +100,7 @@ int main(int argc, char* argv[])
UNITY_BEGIN();
TEST(test_scheduler_t_has_atomic_gc_fields);
return UNITY_END();
}