misc accounting features
This commit is contained in:
parent
f311063a42
commit
6d96109217
2
build.sh
2
build.sh
@ -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
|
echo _OSVERSION=\"PsychOS 2.0a3-$(git rev-parse --short HEAD)\" > target/version.lua
|
||||||
cat target/version.lua target/init.lua > target/tinit.lua
|
cat target/version.lua target/init.lua > target/tinit.lua
|
||||||
mv target/tinit.lua target/init.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 target/version.lua
|
||||||
rm -r doc/ &>/dev/null
|
rm -r doc/ &>/dev/null
|
||||||
$LUA finddesc.lua doc/ $(find lib/ module/ -type f|sort)
|
$LUA finddesc.lua doc/ $(find lib/ module/ -type f|sort)
|
||||||
|
@ -152,8 +152,9 @@ return setmetatable({}, {__index = function(t,k)
|
|||||||
if path then
|
if path then
|
||||||
local fn, e = loadfile(path)
|
local fn, e = loadfile(path)
|
||||||
if not fn then error(string.format("\n - %s",e)) end
|
if not fn then error(string.format("\n - %s",e)) end
|
||||||
return function()
|
return function(...)
|
||||||
local pid = os.spawn(fn,path)
|
local tA = {...}
|
||||||
|
local pid = os.spawn(function() return fn(table.unpack(tA)) end,path)
|
||||||
local ret = {require("event").pull("process_finished",pid)}
|
local ret = {require("event").pull("process_finished",pid)}
|
||||||
if not ret[3] then
|
if not ret[3] then
|
||||||
error(string.format("\n - %s",ret[4]))
|
error(string.format("\n - %s",ret[4]))
|
||||||
|
@ -12,6 +12,8 @@ function os.spawn(f,n) -- function string -- number -- creates a process from fu
|
|||||||
n=n, -- process name
|
n=n, -- process name
|
||||||
p=nPid, -- process PID
|
p=nPid, -- process PID
|
||||||
P=cPid, -- parent PID
|
P=cPid, -- parent PID
|
||||||
|
t=0, -- CPU time
|
||||||
|
T=0, -- total uptime
|
||||||
e={} -- environment variables
|
e={} -- environment variables
|
||||||
}
|
}
|
||||||
if tTasks[cPid] then
|
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
|
function os.taskInfo(pid) -- number -- table -- returns info on process *pid* as a table with name and parent values
|
||||||
pid = pid or os.pid()
|
pid = pid or os.pid()
|
||||||
if not tTasks[pid] then return false end
|
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
|
end
|
||||||
function os.sched() -- the actual scheduler function
|
function os.sched() -- the actual scheduler function
|
||||||
os.sched = nil
|
os.sched = nil
|
||||||
@ -47,7 +49,9 @@ function os.sched() -- the actual scheduler function
|
|||||||
for k,v in pairs(tTasks) do
|
for k,v in pairs(tTasks) do
|
||||||
if coroutine.status(v.c) ~= "dead" then
|
if coroutine.status(v.c) ~= "dead" then
|
||||||
cPid = k
|
cPid = k
|
||||||
|
local sT, sC = os.clock(), computer.uptime()
|
||||||
coroutine.resume(v.c,table.unpack(tEv))
|
coroutine.resume(v.c,table.unpack(tEv))
|
||||||
|
v.t, v.T = v.t + os.clock() - sT, v.T + computer.uptime() - sC
|
||||||
else
|
else
|
||||||
tTasks[k] = nil
|
tTasks[k] = nil
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user