added a way to run OSes as processes
This commit is contained in:
parent
635f9aacd2
commit
a1b0507479
26
modules/base/virt.lua
Normal file
26
modules/base/virt.lua
Normal file
@ -0,0 +1,26 @@
|
||||
do
|
||||
local fs=component.proxy(computer.bootAddress())
|
||||
local fi=fs.open("/boot.lua","rb")
|
||||
local nc,ls,ne="","",{}
|
||||
repeat
|
||||
ls=ls..nc
|
||||
nc=fs.read(fi,2048)
|
||||
until nc == "" or nc == nil
|
||||
fs.close(fi)
|
||||
setmetatable(ne,{__index=_G})
|
||||
ne.computer = _G.computer
|
||||
function ne.computer.pullSignal(n)
|
||||
local et = computer.uptime()+n
|
||||
while true do
|
||||
local eT = {C.yield()}
|
||||
if eT ~= {} then
|
||||
return table.unpack(eT)
|
||||
elseif computer.uptime() >= et then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local fscr=load(ls)
|
||||
setfenv(ls,ne)
|
||||
s("virt process",fscr)
|
||||
end
|
Loading…
Reference in New Issue
Block a user