adding clock system call
This commit is contained in:
@@ -92,6 +92,8 @@ pub fn run(case: []const u8, boot_information: *const BootInformation) void {
|
||||
iommuTest();
|
||||
} else if (eql(case, "ioport")) {
|
||||
ioPortTest();
|
||||
} else if (eql(case, "clock")) {
|
||||
clockTest();
|
||||
} else if (eql(case, "smp")) {
|
||||
smpTest();
|
||||
} else if (eql(case, "affinity")) {
|
||||
@@ -1100,6 +1102,30 @@ fn ioPortTest() void {
|
||||
result();
|
||||
}
|
||||
|
||||
/// The monotonic clock (the source `clock()` surfaces to user space). It must be
|
||||
/// calibrated, move forward over a spin, and never run backwards — the guarantees a
|
||||
/// driver's deadline timeout depends on. The syscall is a thin wrapper over this same
|
||||
/// `architecture.nanos()`.
|
||||
fn clockTest() void {
|
||||
log("DANOS-TEST-BEGIN: clock\n", .{});
|
||||
const t0 = architecture.nanos();
|
||||
check("monotonic clock is calibrated (nonzero)", t0 != 0);
|
||||
|
||||
var last = t0;
|
||||
var monotonic = true;
|
||||
var advanced = false;
|
||||
var i: u32 = 0;
|
||||
while (i < 1_000_000) : (i += 1) {
|
||||
const t = architecture.nanos();
|
||||
if (t < last) monotonic = false;
|
||||
if (t > t0) advanced = true;
|
||||
last = t;
|
||||
}
|
||||
check("clock advanced over the spin", advanced);
|
||||
check("clock never ran backwards (monotonic)", monotonic);
|
||||
result();
|
||||
}
|
||||
|
||||
var proc_worker_run: bool = true;
|
||||
var proc_worker_ran: bool = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user