1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-12-24 11:48:42 -05:00

misc accounting features

This commit is contained in:
XeonSquared 2023-07-04 18:25:11 +10:00
parent f311063a42
commit 6d96109217
3 changed files with 9 additions and 4 deletions

View File

@ -6,7 +6,7 @@ $LUA build.lua module/init.lua target/init.lua
echo _OSVERSION=\"PsychOS 2.0a3-$(git rev-parse --short HEAD)\" > target/version.lua
cat target/version.lua target/init.lua > target/tinit.lua
mv target/tinit.lua target/init.lua
cp -r service/ lib/ cfg/ target/
cp -r service/ lib/ cfg/ exec/ target/
rm target/version.lua
rm -r doc/ &>/dev/null
$LUA finddesc.lua doc/ $(find lib/ module/ -type f|sort)

View File

@ -152,8 +152,9 @@ return setmetatable({}, {__index = function(t,k)
if path then
local fn, e = loadfile(path)
if not fn then error(string.format("\n - %s",e)) end
return function()
local pid = os.spawn(fn,path)
return function(...)
local tA = {...}
local pid = os.spawn(function() return fn(table.unpack(tA)) end,path)
local ret = {require("event").pull("process_finished",pid)}
if not ret[3] then
error(string.format("\n - %s",ret[4]))

View File

@ -12,6 +12,8 @@ function os.spawn(f,n) -- function string -- number -- creates a process from fu
n=n, -- process name
p=nPid, -- process PID
P=cPid, -- parent PID
t=0, -- CPU time
T=0, -- total uptime
e={} -- environment variables
}
if tTasks[cPid] then
@ -38,7 +40,7 @@ end
function os.taskInfo(pid) -- number -- table -- returns info on process *pid* as a table with name and parent values
pid = pid or os.pid()
if not tTasks[pid] then return false end
return {name=tTasks[pid].n,parent=tTasks[pid].P}
return {name=tTasks[pid].n,parent=tTasks[pid].P,cputime=tTasks[pid].t,iotime=tTasks[pid].T}
end
function os.sched() -- the actual scheduler function
os.sched = nil
@ -47,7 +49,9 @@ function os.sched() -- the actual scheduler function
for k,v in pairs(tTasks) do
if coroutine.status(v.c) ~= "dead" then
cPid = k
local sT, sC = os.clock(), computer.uptime()
coroutine.resume(v.c,table.unpack(tEv))
v.t, v.T = v.t + os.clock() - sT, v.T + computer.uptime() - sC
else
tTasks[k] = nil
end