mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
style(ke): rename timecounter to time
This commit is contained in:
+1
-1
@@ -96,7 +96,7 @@ pub fn log(
|
||||
|
||||
var res = ringbuffer.reserve(discarder.fullCount()) catch return;
|
||||
|
||||
res.info.timestamp = ke.timecounter.read_time_nano();
|
||||
res.info.timestamp = ke.time.read_time_nano();
|
||||
res.info.length = @truncate(discarder.fullCount());
|
||||
|
||||
res.buf = std.fmt.bufPrint(res.buf, fmt ++ "\n", args) catch return;
|
||||
|
||||
@@ -25,7 +25,7 @@ pub const log = @import("log.zig");
|
||||
pub const cpu = @import("cpu.zig");
|
||||
pub const thread = @import("thread.zig");
|
||||
pub const dpc = @import("dpc.zig");
|
||||
pub const timecounter = @import("timecounter.zig");
|
||||
pub const time = @import("time.zig");
|
||||
pub const sched = @import("sched.zig");
|
||||
pub const wait = @import("wait.zig");
|
||||
pub const timer = @import("timer.zig");
|
||||
|
||||
+8
-10
@@ -10,8 +10,12 @@ pub const Ipl = p.ipl.Ipl;
|
||||
pub const SpinLock = p.spinlock.SpinLock;
|
||||
pub const Thread = p.thread.Thread;
|
||||
pub const Dpc = p.dpc.Dpc;
|
||||
pub const TimeCounter = p.timecounter.TimeCounter;
|
||||
pub const TimeCounter = p.time.TimeCounter;
|
||||
pub const Timer = p.timer.Timer;
|
||||
pub const Console = p.log.Console;
|
||||
pub const Cpu = p.cpu.Cpu;
|
||||
pub const CpuLocal = p.cpu.CpuLocal;
|
||||
pub const CpuMask = p.cpu.CpuMask;
|
||||
|
||||
// === Exported Interfaces ===
|
||||
pub const panic = p.panic.panic;
|
||||
@@ -30,9 +34,9 @@ pub const dpc = struct {
|
||||
pub const enqueue = p.dpc.enqueue;
|
||||
};
|
||||
|
||||
pub const timecounter = struct {
|
||||
pub const register = p.timecounter.register;
|
||||
pub const read_time_nano = p.timecounter.read_time_nano;
|
||||
pub const time = struct {
|
||||
pub const register_source = p.time.register_source;
|
||||
pub const read_time_nano = p.time.read_time_nano;
|
||||
};
|
||||
|
||||
pub const sched = struct {
|
||||
@@ -56,12 +60,6 @@ pub const log = struct {
|
||||
pub const log = p.log.log;
|
||||
};
|
||||
|
||||
pub const Console = p.log.Console;
|
||||
|
||||
pub const Cpu = p.cpu.Cpu;
|
||||
pub const CpuLocal = p.cpu.CpuLocal;
|
||||
pub const CpuMask = p.cpu.CpuMask;
|
||||
|
||||
comptime {
|
||||
if (!@hasDecl(p.impl, "curcpu")) @compileError("impl must provide curcpu()");
|
||||
}
|
||||
|
||||
+2
-2
@@ -228,7 +228,7 @@ pub fn block() void {
|
||||
td.lock.acquire_no_ipl();
|
||||
|
||||
td.state = .Blocked;
|
||||
td.sleep_start = ke.timecounter.read_time_nano();
|
||||
td.sleep_start = ke.time.read_time_nano();
|
||||
td.runq = null;
|
||||
|
||||
yield(ke.curcpu());
|
||||
@@ -241,7 +241,7 @@ pub fn block() void {
|
||||
pub fn unblock(td: *ke.Thread) void {
|
||||
const ipl = td.lock.acquire();
|
||||
|
||||
td.sleep_time = (ke.timecounter.read_time_nano() - td.sleep_start) / std.time.ns_per_ms;
|
||||
td.sleep_time = (ke.time.read_time_nano() - td.sleep_start) / std.time.ns_per_ms;
|
||||
|
||||
if (td.sleep_time >= config.CONFIG_SCHED_TIMESLICE and td.priority_class == .Batch) {
|
||||
// If we have slept for more than a tick, update interactivity.
|
||||
|
||||
@@ -60,7 +60,7 @@ fn ticks_to_ns(tc: *TimeCounter, count: u64) u64 {
|
||||
/// Register a time-keeping source.
|
||||
/// The TimeCounter will be used if it is the highest quality one available.
|
||||
/// This function cannot be safely called when the hardware timer has been started, as data races on `best_tc` are not avoided.
|
||||
pub fn register(tc: *TimeCounter) void {
|
||||
pub fn register_source(tc: *TimeCounter) void {
|
||||
// Precompute scaling factors for the fast multiply-shift path.
|
||||
// This is meant to avoid 128-bit division and only use multiplication for 64-bit counters.
|
||||
if (tc.mask == std.math.maxInt(u64)) {
|
||||
+4
-4
@@ -75,7 +75,7 @@ pub fn set(timer: *Timer, time: b.Nanoseconds, dpc: ?*ke.Dpc) void {
|
||||
defer cpu.lock.release_no_ipl();
|
||||
|
||||
// Initialize the timer.
|
||||
timer.deadline = ke.timecounter.read_time_nano() + time;
|
||||
timer.deadline = ke.time.read_time_nano() + time;
|
||||
|
||||
timer.cpu = cpu;
|
||||
timer.dpc = dpc;
|
||||
@@ -134,7 +134,7 @@ pub fn clock() void {
|
||||
ke.dpc.enqueue(&percpu.local().dpc, null);
|
||||
// Check for overflows.
|
||||
// This is fine to call a lot, as the function only gets expensive (i.e seqlock store) when an overflow actually happens.
|
||||
ki.timecounter.update_overflow();
|
||||
ki.time.update_overflow();
|
||||
}
|
||||
|
||||
// Called in a DPC when a timer has expired.
|
||||
@@ -143,7 +143,7 @@ fn handle_expiry(_: ?*anyopaque) void {
|
||||
const cpu = percpu.local();
|
||||
|
||||
while (true) {
|
||||
const curtime = ke.timecounter.read_time_nano();
|
||||
const curtime = ke.time.read_time_nano();
|
||||
|
||||
cpu.lock.acquire_no_ipl();
|
||||
|
||||
@@ -162,7 +162,7 @@ fn handle_expiry(_: ?*anyopaque) void {
|
||||
cpu.lock.release_no_ipl();
|
||||
|
||||
// Re-check in case the timer expired while we were here.
|
||||
const now = ke.timecounter.read_time_nano();
|
||||
const now = ke.time.read_time_nano();
|
||||
if (next.deadline <= now or next.deadline - now <= std.time.ns_per_ms) {
|
||||
continue; // expired in the meantime, loop again
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ pub fn init() void {
|
||||
|
||||
posix.sigaction(posix.SIG.ALRM, &act, null);
|
||||
|
||||
ke.timecounter.register(&tc);
|
||||
ke.time.register_source(&tc);
|
||||
}
|
||||
|
||||
pub fn init_cpu() void {
|
||||
|
||||
Reference in New Issue
Block a user