added a way to run OSes as processes

This commit is contained in:
Izaya 2017-06-26 12:48:21 +00:00
parent 635f9aacd2
commit a1b0507479

26
modules/base/virt.lua Normal file
View 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