diff --git a/src/scheduler/include/scheduler.h b/src/scheduler/include/scheduler.h index 10655aae..3c35f2f6 100644 --- a/src/scheduler/include/scheduler.h +++ b/src/scheduler/include/scheduler.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -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*, diff --git a/src/scheduler/testsuite/meson.build b/src/scheduler/testsuite/meson.build index c1fa551f..43028219 100644 --- a/src/scheduler/testsuite/meson.build +++ b/src/scheduler/testsuite/meson.build @@ -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', '.') diff --git a/src/scheduler/testsuite/test.c b/src/scheduler/testsuite/test.c index 4e4dc2d4..be2db2da 100644 --- a/src/scheduler/testsuite/test.c +++ b/src/scheduler/testsuite/test.c @@ -2,8 +2,19 @@ #include #include #include +#include #include +/* 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(); }