mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-11-23 10:58:06 +11:00
fix Glacier GPU allocation, move Icecap root request higher up
This commit is contained in:
parent
981ea559c6
commit
584108d6af
@ -94,25 +94,36 @@ local function announceFreeMonitor(address, except)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getGPU(monitor)
|
local function getGPU(monitor)
|
||||||
local bestG
|
local bestG, bestStats = nil, {-math.huge, -math.huge, -math.huge}
|
||||||
local bestD = 0
|
currentGPUBinding = {}
|
||||||
for v in gpus.list() do
|
for v in gpus.list() do
|
||||||
v.bind(monitor.address, false)
|
v.bind(monitor.address, false)
|
||||||
currentGPUBinding[v.address] = nil
|
|
||||||
local w, h = v.maxResolution()
|
local w, h = v.maxResolution()
|
||||||
local d = v.maxDepth() * w * h
|
local quality = w * h * v.maxDepth()
|
||||||
if d > bestD then
|
local users = (currentGPUUsers[v.address] or 0)
|
||||||
bestG = v
|
local gquality = 0
|
||||||
bestD = d
|
for scr in screens.list() do
|
||||||
bestU = currentGPUUsers[v.address] or 0
|
v.bind(scr.address, false)
|
||||||
elseif d == bestD then
|
w, h = v.maxResolution()
|
||||||
if (currentGPUUsers[v.address] or 0) < bestU then
|
local squality = w * h * v.maxDepth()
|
||||||
|
gquality = math.max(gquality, squality)
|
||||||
|
end
|
||||||
|
local stats = {quality, -users, -gquality}
|
||||||
|
for i = 1, #stats do
|
||||||
|
if stats[i] > bestStats[i] then
|
||||||
bestG = v
|
bestG = v
|
||||||
bestD = d
|
bestStats = stats
|
||||||
bestU = currentGPUUsers[v.address] or 0
|
break
|
||||||
|
elseif stats[i] < bestStats[i] then
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if bestG then
|
||||||
|
neo.emergency("glacier bound " .. monitor.address .. " to " .. bestG.address)
|
||||||
|
else
|
||||||
|
neo.emergency("glacier failed to bind " .. monitor.address)
|
||||||
|
end
|
||||||
return bestG
|
return bestG
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
-- In general, this is what userspace will be interacting with in some way or another to get stuff done
|
-- In general, this is what userspace will be interacting with in some way or another to get stuff done
|
||||||
|
|
||||||
local settings = neo.requireAccess("x.neo.sys.manage", "security sysconf access")
|
local settings = neo.requireAccess("x.neo.sys.manage", "security sysconf access")
|
||||||
|
|
||||||
local fs = neo.requireAccess("c.filesystem", "file managers")
|
local fs = neo.requireAccess("c.filesystem", "file managers")
|
||||||
|
|
||||||
local donkonitDFProvider = neo.requireAccess("r.neo.pub.base", "creating basic NEO APIs")
|
local donkonitDFProvider = neo.requireAccess("r.neo.pub.base", "creating basic NEO APIs")
|
||||||
|
local rootAccess = neo.requireAccess("k.root", "installing GUI integration")
|
||||||
|
|
||||||
local targsDH = {} -- data disposal
|
local targsDH = {} -- data disposal
|
||||||
|
|
||||||
@ -280,7 +279,6 @@ local function wrapWASS(perm, req)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Connect in security policy now
|
-- Connect in security policy now
|
||||||
local rootAccess = neo.requireAccess("k.root", "installing GUI integration")
|
|
||||||
local backup = rootAccess.securityPolicyINIT or rootAccess.securityPolicy
|
local backup = rootAccess.securityPolicyINIT or rootAccess.securityPolicy
|
||||||
rootAccess.securityPolicyINIT = backup
|
rootAccess.securityPolicyINIT = backup
|
||||||
rootAccess.securityPolicy = function (pid, proc, perm, req)
|
rootAccess.securityPolicy = function (pid, proc, perm, req)
|
||||||
|
@ -21,6 +21,28 @@ As it runs in a coroutine, events are
|
|||||||
and potentially accesses headed in
|
and potentially accesses headed in
|
||||||
its direction...)
|
its direction...)
|
||||||
|
|
||||||
|
NOTE regarding security of this!
|
||||||
|
|
||||||
|
For efficiency, APIs are generally
|
||||||
|
used "directly". This allows read
|
||||||
|
access to all events, including any
|
||||||
|
security responses.
|
||||||
|
|
||||||
|
The assumption made here is that if
|
||||||
|
you're communicating with an app you
|
||||||
|
don't trust, you will wrap access to
|
||||||
|
it in a coroutine shell, and perform
|
||||||
|
ensureType usage on everything that
|
||||||
|
it spews out.
|
||||||
|
|
||||||
|
In particular, this is a good way to
|
||||||
|
isolate yourself from any effects,
|
||||||
|
including timeout, of a function you
|
||||||
|
know to be environment-sandboxed:
|
||||||
|
|
||||||
|
coroutine.resume(coroutine.create(
|
||||||
|
functionIDontTrust))
|
||||||
|
|
||||||
An example KittenOS NEO program,
|
An example KittenOS NEO program,
|
||||||
solely using kernel APIs,
|
solely using kernel APIs,
|
||||||
that you will likely have to kill:
|
that you will likely have to kill:
|
||||||
|
Loading…
Reference in New Issue
Block a user