feat(scheduler-allocation): add forward-compatible allocation-mode field

Adds xce_alloc_mode_t (XCE_ALLOC_NORMAL=0, XCE_ALLOC_PREEMPT, with
commented-out RESERVE/BACKFILL placeholders) and alloc_mode on
xce_sched_ctx_t, zero-defaulted by sched_ctx_init()'s existing
memset. Purely additive: nothing branches on the field yet -- this
spec only declares the extension point scheduler-preemption needs.

Task 1.3 (scheduler-allocation spec). Requirement 9.5.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYdtrEWWZfKRRGED7raEYg
This commit is contained in:
Rongsong Shen 2026-09-04 15:17:30 +00:00
parent 5a6706761d
commit d8b5cf8718
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
3 changed files with 52 additions and 1 deletions

View file

@ -372,6 +372,36 @@ test_update_queue_null_returns_einval(void)
TEST_ASSERT_EQUAL_INT(-EINVAL, sched_update_existing_queue(&sched, NULL));
}
/* Allocation-mode extension point (scheduler-allocation spec, task 1.3,
* Req 9.5). Pulls the REAL sched_ctx_init() (via the schedobj.c #include
* above) to prove memset-zero-init alone defaults a freshly-initialized
* xce_sched_ctx_t's alloc_mode to XCE_ALLOC_NORMAL -- no explicit
* assignment needed in sched_ctx_init() since XCE_ALLOC_NORMAL is the
* enum's zero value. */
static void
test_ctx_init_defaults_alloc_mode_to_normal(void)
{
xce_scheduler_t sched;
fixture_init(&sched);
/* XCE_ALLOC_NORMAL must be exactly 0 for memset-zero-init to default
* to it -- pin the enum value itself, not just the observed field. */
TEST_ASSERT_EQUAL_INT(0, XCE_ALLOC_NORMAL);
xce_sched_obj_t obj;
memset(&obj, 0, sizeof(obj));
obj.tag = XCE_RESREQ_PRIMARY;
xce_sched_ctx_t ctx;
int rc = sched_ctx_init(&ctx, &sched, &obj);
TEST_ASSERT_EQUAL_INT(0, rc);
TEST_ASSERT_EQUAL_INT(XCE_ALLOC_NORMAL, ctx.alloc_mode);
sched_ctx_fini(&ctx);
}
int main(int argc, char* argv[])
{
(void)argc; (void)argv;
@ -386,5 +416,6 @@ int main(int argc, char* argv[])
RUN_TEST(test_update_existing_queue_real, 0);
RUN_TEST(test_update_unknown_queue_returns_enoent, 0);
RUN_TEST(test_update_queue_null_returns_einval, 0);
RUN_TEST(test_ctx_init_defaults_alloc_mode_to_normal, 0);
return UNITY_END();
}