feat: add _Atomic gc-predicate fields to xce_scheduler_t (phase 6 task 6-3)
This commit is contained in:
parent
4e177047c9
commit
823a66e91e
3 changed files with 30 additions and 2 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <rtti.h>
|
#include <rtti.h>
|
||||||
|
#include <stdatomic.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
@ -83,6 +84,9 @@ typedef struct {
|
||||||
cbuf_t wbuf; /* action to trigger scheduling */
|
cbuf_t wbuf; /* action to trigger scheduling */
|
||||||
cbuf_t jbuf; /* job picked for allocation */
|
cbuf_t jbuf; /* job picked for allocation */
|
||||||
cbuf_t decisions; /* scheduler decisions */
|
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;
|
} xce_scheduler_t;
|
||||||
|
|
||||||
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,
|
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ scheduler_test_src = [
|
||||||
'test.c'
|
'test.c'
|
||||||
]
|
]
|
||||||
|
|
||||||
scheduler_test_deps = [libxce_deps, librtti_dep, unity_dep]
|
scheduler_test_deps = [librtti_dep, unity_dep]
|
||||||
|
|
||||||
incdir = include_directories('../include', '../../include', '.')
|
incdir = include_directories('../include', '../../include', '.')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,19 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdatomic.h>
|
||||||
#include <unity/unity.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 setUp() { return; }
|
||||||
|
|
||||||
void tearDown(void)
|
void tearDown(void)
|
||||||
|
|
@ -65,10 +76,21 @@ static int check_test(struct arguments* args, char* x)
|
||||||
return 0;
|
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) \
|
#define TEST(x) \
|
||||||
do { \
|
do { \
|
||||||
if (check_test(&arguments, #x)) { \
|
if (check_test(&arguments, #x)) { \
|
||||||
x(); \
|
RUN_TEST(x, 0); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
@ -78,5 +100,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
|
|
||||||
|
TEST(test_scheduler_t_has_atomic_gc_fields);
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue