1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-12-25 02:18:07 +11:00

Clean up some stuff / Lua 5.2 warning message / late fixes. R0

This commit is contained in:
20kdc 2018-03-29 22:03:52 +01:00
parent 902ff12d22
commit 89d8c7fd82
6 changed files with 78 additions and 58 deletions

View File

@ -1,17 +1,18 @@
# KittenOS NEO
### efficient. multi-tasking. clean. security-oriented.
# KittenOS NEO (pre-release)
# WARNING! STATUS: UNSTABLE!
As per usual, no warranty, not my responsibility if this breaks, or if you somehow try to run it on an actual (non-OpenComputers) computer.
The first commit is after I got the installer working again after the new compression system (BDIVIDE).
The older compression systems (which are not compatible with `heroes.lua`) are kept in preSH.tar.gz in case you want to see how NOT to do things.
That's what the "SYSTEM HEROES" thing is about.
## Description
At least in theory: "efficient. multi-tasking. clean. security-oriented".
KittenOS NEO is an OpenComputers operating system designed for Tier 1 hardware.
This means, among other things, it has an operating overhead limit of 192KiB real-world (on 32-bit).
This means, among other things, it has an operating overhead limit of 192KiB real-world (on 32-bit or 64-bit).
Unlike the original KittenOS (now in the "legacy" branch), it is also designed with some attempt at cleanliness.
@ -35,6 +36,8 @@ As the installer must be loaded in full into RAM, this is not negotiable.
If it can't be kept this way with the current compressor, then a better compressor will have to be made.
Everything following is completely a draft. This is more like a guideline rather than actual policy.
All kernel or security-critical `sys-` process bugs will cause an installer update.
Other bugs will merely result in an updated copy in the repository.
@ -43,9 +46,9 @@ This copy will be copied to installer code if and only if another condition requ
The code in the `code/` folder is the code meant for the installer.
Non-installer code is in the `repository/`, (WORKING ON THIS) and thus accessible via CLAW.
Non-installer code is in the `repository/`, and thus accessible via CLAW.
(NOTE: HTTPS is not used for this due to OC/OCEmu issues.)
As HTTPS is not used for this due to various weirdness that occurs when I try, I'm hosting the repository and `inst.lua` at `http://20kdc.duckdns.org/neo`.
Requests for additional features in system APIs will NOT cause an installer update.
@ -53,19 +56,29 @@ Requests for additional features in system APIs will NOT cause an installer upda
The tools are meant for internal use, so are thus designed to run on some generic Unix.
Firstly, you can create a "raw installer" (uncompressed) with `mkucinst.lua`.
The tools that I haven't gotten rid of are the ones that still work properly.
This executes `tar -cf code.tar code`, which you will need to do in any case - the installer contains a compressed TAR.
Firstly, for an uncompressed installer (just to test installer basecode), you use `mkucinst.lua`.
Secondly, for a compressed installer, after creating the TAR, `symsear-st1.sh`, `symsear-st2.sh`, and `symsear-st4.sh` (st3 is executed by st2) are used.
This kind of has some overlap with `package.sh` so that needs to be dealt with at some point.
Secondly, for a compressed installer, you use `package.sh` to rebuild `code.tar`, then use something along the lines of:
lua heroes.lua `wc -c code.tar` > inst.lua
This will build the compressed installer.
## Kernel Architecture
KittenOS NEO is an idea of what a Lua-based efficient microkernel would look like.
KittenOS NEO is an idea of what a Lua-based efficient microkernel might look like.
Scheduling is based entirely around uptime and timers,
which cause something to be executed at a given uptime.
That said, for a microkernel it's still a bit larger than I'd have hoped.
If anyone has any ideas, put them in an issue? If they're not too damaging, I'll use the saved space to add a thank-you-note to them in the kernel.
## Installer Architecture
The installer is split into a generic TAR extractor frontend `insthead.lua` and a replacable compression backend (written in by relevant tools - in current versions, `heroes.lua` is where it starts).

View File

@ -145,10 +145,15 @@ local function setupMonitor(gpu, monitor)
local maxD = gpu.maxDepth()
local w, h, d, t = getMonitorSettings(monitor.address)
w, h, d = math.min(w, maxW), math.min(h, maxH), math.min(d, maxD)
monitor.setTouchModeInverted(t == "yes")
if monitor.setTouchModeInverted then
monitor.setTouchModeInverted(t == "yes")
else
t = "no"
end
settings["scr.w." .. monitor.address] = tostring(w)
settings["scr.h." .. monitor.address] = tostring(h)
settings["scr.d." .. monitor.address] = tostring(d)
settings["scr.t." .. monitor.address] = t
sRattle("scr.w." .. monitor.address, tostring(w))
sRattle("scr.h." .. monitor.address, tostring(h))
sRattle("scr.d." .. monitor.address, tostring(d))

View File

@ -157,8 +157,13 @@ local function finalPrompt()
return false
end
end
warnings[1] = "TAB to change option,"
warnings[2] = "ENTER to select..."
if _VERSION == "Lua 5.2" then
warnings[1] = "NOTE: It's recommended you use Lua 5.3."
warnings[2] = "Shift-right-click while holding the CPU item."
else
warnings[1] = "TAB to change option,"
warnings[2] = "ENTER to select..."
end
-- The actual main prompt loop
while waiting do
local gpu = gpuG()

View File

@ -244,7 +244,9 @@ function lister(pfx)
end
function baseProcEnv()
return {math = wrapMath,
local pe = {
_VERSION = _VERSION,
math = wrapMath,
table = wrapTable,
string = wrapString,
unicode = wrapUnicode,
@ -287,6 +289,9 @@ function baseProcEnv()
ensureType = ensureType
}
}
pe._G = pe
pe._ENV = pe
return pe
end
function loadLibraryInner(library)
@ -562,44 +567,41 @@ end
if not start("sys-init") then error("Could not start sys-init") end
while true do
local ok, r = pcall(function()
local tmr = nil
for i = 1, 16 do
tmr = nil
local now = computer.uptime()
local breaking = false -- Used when a process dies - in this case it's assumed OC just did something drastic
local didAnything = false
local k = 1
while timers[k] do
local v = timers[k]
if v[1] <= now then
table.remove(timers, k)
if v[2](table.unpack(v, 3)) then
breaking = true
tmr = 0.05
break
end
didAnything = true
else
if not tmr then
tmr = v[1]
else
tmr = math.min(tmr, v[1])
end
k = k + 1
local tmr = nil
for i = 1, 16 do
tmr = nil
local now = computer.uptime()
local breaking = false -- Used when a process dies - in this case it's assumed OC just did something drastic
local didAnything = false
local k = 1
while timers[k] do
local v = timers[k]
if v[1] <= now then
table.remove(timers, k)
if v[2](table.unpack(v, 3)) then
breaking = true
tmr = 0.05
break
end
didAnything = true
else
if not tmr then
tmr = v[1]
else
tmr = math.min(tmr, v[1])
end
k = k + 1
end
if breaking then break end
-- If the system didn't make any progress, then we're waiting for a signal (this includes timers)
if not didAnything then break end
end
now = computer.uptime() -- the above probably took a while
local dist = tmr and math.max(0.05, tmr - now)
local signal = {computer.pullSignal(dist)}
idleTime = idleTime + (computer.uptime() - now)
if signal[1] then
distEvent(nil, "h." .. signal[1], select(2, table.unpack(signal)))
end
end)
if not ok then emergencyFunction("K-WARN " .. tostring(r)) end
if breaking then break end
-- If the system didn't make any progress, then we're waiting for a signal (this includes timers)
if not didAnything then break end
end
now = computer.uptime() -- the above probably took a while
local dist = tmr and math.max(0.05, tmr - now)
local signal = {computer.pullSignal(dist)}
idleTime = idleTime + (computer.uptime() - now)
if signal[1] then
distEvent(nil, "h." .. signal[1], select(2, table.unpack(signal)))
end
end

View File

@ -1,11 +1,6 @@
-- This is released into the public domain where possible.
-- This is released into the public domain.
-- No warranty is provided, implied or otherwise.
-- SYSTEM HEROES.
-- Nabbed Sonic Heroes lyrics follow:
-- "What comes up, must come down... "
-- "Yet, my feet don't touch the ground..."
-- arg is the size of the code.tar file
local arg = ...
os.execute("lua com2/preproc.lua < code.tar | lua com2/bdivide.lua > com2/code.tar.bd")

Binary file not shown.