1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-23 19:08:05 +11:00

fix Glacier GPU allocation, move Icecap root request higher up

This commit is contained in:
20kdc 2018-04-22 22:15:00 +01:00
parent 981ea559c6
commit 584108d6af
3 changed files with 46 additions and 15 deletions

View File

@ -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)
local gquality = 0
for scr in screens.list() do
v.bind(scr.address, false)
w, h = v.maxResolution()
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 d == bestD then elseif stats[i] < bestStats[i] then
if (currentGPUUsers[v.address] or 0) < bestU then break
bestG = v
bestD = d
bestU = currentGPUUsers[v.address] or 0
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

View File

@ -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)

View File

@ -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: