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:
parent
5a6706761d
commit
d8b5cf8718
3 changed files with 52 additions and 1 deletions
|
|
@ -140,6 +140,22 @@ typedef struct {
|
|||
host_eval_ctx_t* host_eval_ctx; /* cached per-session; NULL until first use */
|
||||
} xce_sched_worker_t;
|
||||
|
||||
/* Req 9.5 (scheduler-allocation spec): forward-compatible resource-pool-mode
|
||||
* extension point on xce_sched_ctx_t. v1 (this spec) implements only
|
||||
* XCE_ALLOC_NORMAL -- no allocation code path branches on any other value.
|
||||
* XCE_ALLOC_PREEMPT's actual resource-borrowing behavior belongs to the
|
||||
* scheduler-preemption spec; the "Future:" entries are scaffolding for
|
||||
* later resource-pool modes (e.g. reservation-aware backfill) and are not
|
||||
* implemented by anything yet. */
|
||||
typedef enum {
|
||||
XCE_ALLOC_NORMAL = 0, /* only truly free resources */
|
||||
XCE_ALLOC_PREEMPT, /* count preemptible job resources as available */
|
||||
/* Future:
|
||||
* XCE_ALLOC_RESERVE, // count reserved-but-idle resources as available
|
||||
* XCE_ALLOC_BACKFILL, // count reserved + preemptible resources
|
||||
*/
|
||||
} xce_alloc_mode_t;
|
||||
|
||||
typedef struct {
|
||||
void* sched;
|
||||
xce_sched_worker_t* worker;
|
||||
|
|
@ -155,6 +171,10 @@ typedef struct {
|
|||
xce_sched_alloc_req_t alloc_req;
|
||||
xce_job_alloc_t* alloc;
|
||||
xce_pendreason_t* reason;
|
||||
/* Req 9.5: defaults to XCE_ALLOC_NORMAL via sched_ctx_init()'s existing
|
||||
* memset(ctx, 0, sizeof(*ctx)) -- XCE_ALLOC_NORMAL is the enum's zero
|
||||
* value, so no explicit assignment is needed. */
|
||||
xce_alloc_mode_t alloc_mode;
|
||||
} xce_sched_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue