feat(scheduler-sim-decision-parity): relocate resource accounting to core-level (task 1.1)

Relocates sched_account_jobs()/sched_charge_account()/sched_uncharge_account()/
sched_update_account()/sched_update_res_accounts()/sched_commit_job_alloc()
from xce_scheduler_t* to xce_sched_core_t*, mirroring the sched_resolve_job_picker()
precedent, so the simulation driver can call the same accounting service the
normal-mode driver already uses. Pure signature relocation -- every body
reference was already sched->core.*, no logic change. Updates the 3 real call
sites (driver.c's normal-mode round, scheduler.c's sched_begin_session and
sched_commit_decision) and 7 existing tests' link-satisfying stub signatures.

Adds test_resource_accounting.c proving Requirement 1.4: the relocated
accounting produces identical resInUse/sharedInUse output whether called
against a core embedded in xce_scheduler_t or xce_sched_sim_driver_t.

43/44 scheduler tests pass; the 1 failure is pre-existing bug-1560
(unrelated recording.c sandbox-permission ordering issue).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-22 06:04:03 +00:00
parent 0b2c856d8b
commit 3106c82ed0
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
15 changed files with 498 additions and 75 deletions

View file

@ -80,13 +80,16 @@
* sched_account_jobs() (scheduler.c) is instead a SPY test double (this
* file never links scheduler.c) -- same rationale
* test_driver_decision_cb.c/test_driver_translate.c already established
* for sched_publish_dispatch()/sched_publish_pend_reason(): it is
* xce_scheduler_t*-coupled and pulls in resource.c's sched_charge_account()
* machinery, whose OWN resource-accounting correctness is out of THIS
* task's scope (this test's target is the DRIVER's ordering discipline --
* does it call sched_account_jobs() at all, and in the right window --
* not whether sched_account_jobs() itself charges resources correctly,
* which is scheduler-allocation spec territory with its own coverage).
* for sched_publish_dispatch()/sched_publish_pend_reason(): it pulls in
* resource.c's sched_charge_account() machinery, whose OWN resource-
* accounting correctness is out of THIS task's scope (this test's target
* is the DRIVER's ordering discipline -- does it call sched_account_jobs()
* at all, and in the right window -- not whether sched_account_jobs()
* itself charges resources correctly, which is scheduler-allocation spec
* territory, plus test_resource_accounting.c's own coverage as of
* scheduler-sim-decision-parity task 1.1). As of that same task,
* sched_account_jobs() takes xce_sched_core_t* (relocated from
* xce_scheduler_t*) -- this spy's signature matches.
*
* White-box #include of ../src/core.c, ../src/core_clock.c,
* ../src/core_events.c, ../src/core_session.c, ../src/decision.c,
@ -346,8 +349,8 @@ int sched_resolve_job_picker(xce_sched_core_t* core, xce_sched_plugin_t** out)
}
/* sched_account_jobs() itself is defined further below (SPY test double
* section) -- its prototype already comes from scheduler.h, included
* above. */
* section) -- its prototype already comes from core.h (included above via
* scheduler.h). */
void setUp(void) { return; }
void tearDown(void) { return; }
@ -409,9 +412,9 @@ static int find_log_index(ordering_event_tag_t tag)
static _Atomic int g_account_jobs_calls;
int sched_account_jobs(xce_scheduler_t* sched)
int sched_account_jobs(xce_sched_core_t* core)
{
(void)sched;
(void)core;
atomic_fetch_add(&g_account_jobs_calls, 1);
log_event(EVT_ACCOUNT_JOBS);