Attempt to fix

This commit is contained in:
zeng-github01 2025-08-30 02:33:18 +08:00
parent 7d9eac5584
commit 211b81fdd0
3 changed files with 1497 additions and 1370 deletions

View File

@ -47,11 +47,14 @@ local stats = {
}
local function doSleep()
local epsilon = 1e-6
local deadline = computer.uptime() + (tonumber(options.i) or tonumber(options.interval) or 1)
repeat
event.pull(deadline - computer.uptime())
until computer.uptime() >= deadline
local remaining = deadline - computer.uptime()
if remaining <= epsilon then break end
event.pull(math.max(remaining, 0.001))
until computer.uptime() >= deadline - epsilon
end
local function doPing()

View File

@ -25,9 +25,13 @@ end
function os.sleep(timeout)
checkArg(1, timeout, "number", "nil")
local deadline = computer.uptime() + (timeout or 0)
local epsilon = 1e-6
repeat
event.pull(deadline - computer.uptime())
until computer.uptime() >= deadline
local remaining = deadline - computer.uptime()
if remaining <= epsilon then break end
event.pull(math.max(remaining, 0.001))
until computer.uptime() >= deadline - epsilon
end
os.setenv("PATH", "/bin:/usr/bin:/home/bin:.")

File diff suppressed because it is too large Load Diff