made the OS cope with killed tasks

This commit is contained in:
Izaya 2017-07-31 09:39:42 +10:00
parent 5a6018ad5e
commit a95611806d

View File

@ -32,13 +32,13 @@ do -- so local works
eq[#eq+1]={computer.pullSignal(p)} -- add the latest event to the eq eq[#eq+1]={computer.pullSignal(p)} -- add the latest event to the eq
if #eq > 16 then if #eq > 16 then
table.remove(eq,1) -- remove the earliest if the eq is full table.remove(eq,1) -- remove the earliest if the eq is full
for pid,proc in ipairs(tT) do for pid,proc in pairs(tT) do
if proc.ep > 1 then if proc.ep > 1 then
proc.ep = proc.ep - 1 -- decrement pointers for tasks to keep them on the same ones proc.ep = proc.ep - 1 -- decrement pointers for tasks to keep them on the same ones
end end
end end
end end
for pid,proc in ipairs(tT) do for pid,proc in pairs(tT) do
if coroutine.status(proc.c) == "dead" then if coroutine.status(proc.c) == "dead" then
tT[pid] = nil tT[pid] = nil
else else
@ -89,7 +89,7 @@ do -- so local works
end end
function os.tasks() -- returns a table of tasks running on the system function os.tasks() -- returns a table of tasks running on the system
local t = {} local t = {}
for k,v in ipairs(tT) do for k,v in pairs(tT) do
t[k] = v.n t[k] = v.n
end end
return t return t