Home / Docs-Technical WhitePaper / 07-EFT.WP.Core.Threads v1.0
Chapter 1 — Thread Model and Naming
I. Scope and Objects
- Define the primitives, naming, and lifecycle automaton for the concurrency domain: thr, pid_thr, gid, eid, chan, sem, hb, tau_mono / ts, and resource hints R_cpu/R_mem/R_io.
- Provide a unified thread model that covers OS threads, green threads, actors, and coroutines; any independently schedulable and observable execution unit is classified as a thr.
- All symbols and formulas are written in English plain text, with inline symbols wrapped in backticks; cross-volume anchors and numbering follow the series conventions.
II. Core Objects and Identifiers
- Threads and execution units
- thr: an execution unit; pid_thr: globally unique thread identifier; state ∈ {"new","ready","running","blocked","done","canceled"}.
- Attributes: affinity (CPU affinity), prio (priority), K_thr (concurrency cap for a task class).
- Execution graph and dependencies
G = (V,E); dep(u,v); critical path crit(G); node cost w(v), edge cost c(e); makespan T_make(G). - Messages and channels
chan (channel); q_len, cap, bp; msg, ack; idemp_key. - Time and consistency
tau_mono (monotonic clock); ts (UTC wall clock); hb (happens-before); deadline, timeout, cancel_token. - Rates and delay (queueing)
lambda, mu, rho = lambda / mu; L, L_q, W, W_q; Little’s Law L = lambda * W.
III. State Machine and Lifecycle
- State set: state ∈ {"new","ready","running","blocked","done","canceled"}.
- Allowed transitions (minimal closure):
- new -> ready -> running -> done
- running -> blocked -> ready
- any_active -> canceled
- Canonical latency decomposition:
- W = W_q + W_run, where W_q is queueing/resource contention delay and W_run is actual execution time.
- Lateness metric: lateness = max(0, ts_finish - deadline); soft-timeout calibration uses tau_mono.
- Causality:
If hb(e1,e2) holds, then enforce event sequence under the same thread: seq(e1) < seq(e2); out-of-order cases require deduplication and idempotence.
IV. Naming Rules and Encoding (TS.*)
- Unified prefix: TS. is reserved for semantic encoding of thread-domain objects and metrics.
- Structured pattern: <prefix>.<domain>.<kind>.<name>[.attr...], with <domain> ∈ {"core","svc","job","batch"}.
- Identifiers and primary keys:
- TS.pid_thr: thread id. Format ns:base36(ts_ns)+"-"+rand62(8); uniqueness postulate per P71-2.
- TS.gid: execution graph id. Format ns:graph-"+hash_sha256(spec)[0:12].
- TS.eid: event id. Format pid_thr+"#"+seq64; strictly increasing within a given pid_thr.
- Channels and messages:
- TS.chan.name: globally unique channel name; TS.chan.mode ∈ {"mpmc","mpsc","spmc","spsc"}.
- TS.msg.key: idemp_key; TS.msg.sem ∈ {"at_most_once","at_least_once","exactly_once*"}.
- Attributes and resources:
TS.thr.affinity, TS.thr.prio, TS.thr.quota.cpu, TS.thr.quota.mem, TS.thr.quota.io. - Metrics and observability:
TS.sli.latency_ms, TS.sli.queue_time_ms, TS.sli.run_time_ms, TS.sli.qps, TS.sli.err_rate, TS.sli.p99_ms. - Semantic labels (unified tag keys):
svc, comp, op, gid, pid_thr, chan, sem, region, zone, version, schema_version. - Initial catalog (20 entries):
- TS.pid_thr, TS.gid, TS.eid, TS.chan.name, TS.chan.mode, TS.chan.cap
- TS.msg.key, TS.msg.sem, TS.retry.count, TS.timeout.ms
- TS.thr.affinity, TS.thr.prio, TS.thr.K_thr, TS.thr.state
- TS.sli.latency_ms, TS.sli.queue_time_ms, TS.sli.run_time_ms, TS.sli.err_rate
- TS.sli.p99_ms, TS.sli.qps
V. Postulates and Constraints (P71-*)
- P71-1 (Clock consistency): all internal delay, jitter, and timeout measurements use tau_mono; external reporting uses ts.
- P71-2 (Identifier uniqueness): ∀ pid_thr_i ≠ pid_thr_j : pid_thr_i ≠ pid_thr_j; eid is strictly increasing per pid_thr.
- P71-3 (Stability first): any service station in steady state must satisfy rho < 1; otherwise configure bp and rate limiting.
- P71-4 (Idempotence closure): cross-process interactions default to sem="at_least_once"; consumers must enforce exactly_once* via idemp_key and a dedup window Delta_t_dedup.
- P71-5 (Budgetable resources): declare R_cpu/R_mem/R_io bounds before admission to G; scheduling must not exceed quota.
- P71-6 (Observability required): every thr/chan reports at least TS.sli.queue_time_ms, TS.sli.run_time_ms, TS.sli.err_rate, aggregable into SLOs.
VI. Thread Attributes and Scheduling Hints
- Concurrency cap: K_thr sets the maximum concurrent slots for a task class; separate from the rate limiter but must coordinate with it.
- Affinity and priority: affinity maps to CPU sets; prio is an integer scale; bounds are platform-defined in the implementation doc.
- Resource quotas: quota = {"cpu": R_cpu, "mem": R_mem, "io": R_io}; exceeding quotas results in throttle or preempt—never silent drops.
VII. Message Exchange and Delivery Semantics
- Channel capacity and backpressure:
cap is a hard limit; bp = f(q_len, cap, W_q) is monotone; reaching the threshold triggers drop, delay, or shed. - Delivery semantics:
sem="at_most_once": losses allowed, no retries; sem="at_least_once": duplicates allowed, must deduplicate; sem="exactly_once*": best-effort via idemp_key and durable logs. - Idempotence constraint:
Idempotent handlers satisfy f(x; idemp_key) = f(x; idemp_key); the dedup window Delta_t_dedup must be declared.
VIII. Metric Fields and Aggregation Windows
- Latency family: TS.sli.queue_time_ms, TS.sli.run_time_ms, TS.sli.latency_ms = queue_time_ms + run_time_ms.
- Reliability family: TS.sli.err_rate ∈ [0,1], TS.retry.count, TS.drop.count, TS.timeout.count.
- Throughput family: TS.sli.qps, TS.sli.backlog = q_len.
- Quantile family: TS.sli.p50_ms, TS.sli.p95_ms, TS.sli.p99_ms (aggregated over SLA_window).
- Dimensional checks: unit(latency_ms)="ms", dim(latency_ms)="T"; unit(qps)="1/s", dim(qps)="T^-1"; check_dim( L - lambda * W ) = 0.
IX. Compatibility and Cross-Volume References
- With Core.DataSpec: thread metrics, tracing, and logs are written as datasets D (writes R), and the manifest records schema_version and Trace.
- With Core.Equations and the “two-form” arrival-time reference (for time calibration or propagation latency modeling):
- Constant-factored: T_arr = ( 1 / c_ref ) * ( ∫ n_eff d ell )
- General: T_arr = ( ∫ ( n_eff / c_ref ) d ell )
- Discrepancy: delta_form = | ( 1 / c_ref ) * ( ∫ n_eff d ell ) - ( ∫ ( n_eff / c_ref ) d ell ) |.
- Conflict discipline: do not mix T_fil with T_trans; strictly distinguish n and n_eff; always use gamma(ell) and d ell to declare path and measure.
X. TS. Encoding Cards (Examples and Checks)
- TS.pid_thr
- Definition: globally unique thread identifier.
- Form: ns:base36(ts_ns)+"-"+rand62(8); e.g., svcA:kr3t9z2s-1B9xYpQZ.
- Constraint: uniqueness (P71-2); ns uses lowercase letters and dashes.
- TS.eid
- Definition: event identifier (monotonic within a thread).
- Form: pid_thr+"#"+seq64; e.g., svcA:...#0000000F.
- Constraint: strictly increasing per pid_thr (P71-2).
- TS.gid
- Definition: execution graph identifier.
- Form: ns:graph-"+hash_sha256(spec)[0:12].
- Constraint: stable across releases; spec changes yield a new gid.
- TS.chan.name
- Definition: channel name.
- Form: ns.comp.op; e.g., svcA.ingest.parse.
- Constraint: globally unique; mode and cap must be configured.
- TS.msg.sem
- Definition: delivery semantics.
- Values: "at_most_once"|"at_least_once"|"exactly_once*".
- Constraint: consistent with dedup policy (P71-4).
- TS.sli.latency_ms
- Definition: end-to-end latency.
- Form: numeric; unit ms; aggregate p50/p95/p99 over SLA_window.
- Check: latency_ms = queue_time_ms + run_time_ms (within tolerance).
- TS.thr.quota.*
- Definition: resource quotas.
- Form: cpu (cores), mem (bytes or unit suffix), io (MB/s).
- Constraint: must not be exceeded (P71-5).
XI. Minimal Validation Checklist (Mx-1 Extract)
- Identifier checks
validate_unique(TS.pid_thr); validate_monotonic(TS.eid per pid_thr). - Stability checks
Assert rho < 1 or produce a bp policy recommendation. - Idempotence and windows
Require idemp_key when sem!="at_most_once"; declare and persist Delta_t_dedup. - Dimensional closure
check_dim( L - lambda * W ) = 0; unit(latency_ms)="ms".
XII. Terminology Conflict List (Execution × Metrology Cross-Checks)
- T_fil vs T_trans: the former is tension only; the latter is transmission coefficient only.
- n vs n_eff: number density and effective refractive index are not interchangeable; whenever T_arr appears, use n_eff.
- Path and measure: where an integral appears, write it as gamma(ell) with measure d ell, and declare L_gamma = ( ∫ 1 d ell ).
XIII. Summary and Exit Criteria
- Thread-domain objects are uniformly named under TS.*; identifiers and metrics satisfy P71-*; the semantics close over thr/chan/sem/hb with a clear lifecycle.
- Proceed to Chapter 2 (scheduling design) only after:
- TS.pid_thr/TS.gid/TS.eid/TS.chan.* are defined and pass uniqueness and monotonicity checks.
- quota and K_thr are declared and validated against resource budgets.
- SLI field mappings and SLA_window aggregation policies are complete and verifiable.
Copyright & License (CC BY 4.0)
Copyright: Unless otherwise noted, the copyright of “Energy Filament Theory” (text, charts, illustrations, symbols, and formulas) belongs to the author “Guanglin Tu”.
License: This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0). You may copy, redistribute, excerpt, adapt, and share for commercial or non‑commercial purposes with proper attribution.
Suggested attribution: Author: “Guanglin Tu”; Work: “Energy Filament Theory”; Source: energyfilament.org; License: CC BY 4.0.
First published: 2025-11-11|Current version:v5.1
License link:https://creativecommons.org/licenses/by/4.0/