feat(scheduler-core): implement clock virtualization and session timing (task 4.5)

Adds xce_core_now() (new core_clock.c, kept separate from core.c so
test_core_isolation.c's wall-clock scan still enforces zero direct
clock_gettime()/time() calls elsewhere in the core): the two-anchor
plus speed formula (virtual_clock_base + (elapsed * speed_num) /
speed_den), covering all four modes (normal, discrete/real-time/fast-
slow simulation) via four new atomic fields on xce_sched_core_t,
defaulted to normal-mode (1/1 speed) in xce_sched_core_init().

requirements.md's literal tlog_reg_format_func(fn, core_ptr) call
shape doesn't exist in the real vendored tlog library (registration
takes only the callback; userptr is per-call-site, not bindable at
registration) -- resolved with a module-level active-core pointer read
by a new core-scoped format function, not wired into mylog_init()/
main.c yet. xce_core_go()/xce_core_end_session() (task 4.4) now stamp
session_start/compute session_duration_ns via xce_core_now(), with
their existing session-active/reentrancy behavior untouched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019dw5WnN3DXStaEaPYfACU1
This commit is contained in:
Rongsong Shen 2026-08-04 03:38:58 +00:00
parent de69b6288d
commit c5432f7786
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
9 changed files with 849 additions and 5 deletions

View file

@ -27,11 +27,16 @@
* - xce_core_end_session() clears session_active back to 0, unblocking
* the next xce_core_go() call.
*
* White-box #include of ../src/core.c, ../src/core_session.c, and
* ../src/decision.c (same convention as test_core_events.c/
* test_core_jbuf_capacity_pin.c) so this test exercises the REAL
* xce_sched_core_init()/xce_core_go()/xce_core_end_session()/
* White-box #include of ../src/core.c, ../src/core_session.c,
* ../src/core_clock.c, and ../src/decision.c (same convention as
* test_core_events.c/test_core_jbuf_capacity_pin.c) so this test exercises
* the REAL xce_sched_core_init()/xce_core_go()/xce_core_end_session()/
* xce_core_set_decision_cb()/make_*_decision(), not a re-implementation.
* core_clock.c joined this file's #include list in task 4.5 (scheduler-core
* spec): xce_core_go()/xce_core_end_session() now call xce_core_now()
* (Req 5 AC 12 session timing), which core_clock.c is the only TU that
* defines -- see test_clock.c for that function's own dedicated contract
* tests; this file does not re-test the clock formula itself.
* Unlike test_core_events.c, this file does not need core_events.c or a
* working picker plugin resolution -- xce_core_go()/xce_core_end_session()
* never call sched_resolve_job_picker() (verified: grep confirms neither
@ -54,6 +59,7 @@
* xce_core_end_session()/xce_core_set_decision_cb()/make_*_decision()
* under test into this TU (white-box #include). */
#include "../src/core.c"
#include "../src/core_clock.c"
#include "../src/core_session.c"
#include "../src/decision.c"