This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kieran's profile picture

KAOS: Boring-looking, multitasking operating system

Started by Kieran, 14 February 2014 - 11:58 AM
Kieran #1
Posted 14 February 2014 - 12:58 PM
In my naivety (and lack of looking at this forum), I somehow thought a multitasking CC operating system that supports native CraftOS programs would be something new and interesting. Much to my surprise (not really), it isn't. Anyway, as a result, I've spent the last few days making KAOS.

KAOS accomplishes multitasking by sandboxing the default CraftOS shell, while intercepting events and API calls. KAOS-aware programs (such as the included task manager) may reach out of the sandbox and interact with the other processes and more.

I think I've managed to iron out most bugs, so it should be relatively usable by now. KAOS is pretty lightweight in its current state, and it doesn't ship with anything other than the "kernel", a couple of system services and the aforementioned task manager. It also currently does not support shutting down - calling os.shutdown() will simply exit the active process. It does support rebooting, though.

KAOS doesn't have window management and all process currently take up all (well, most of) the screen when they are active. As awesome as some of the windowing OSes are, I feel that it's a somewhat pointless exercise considering the screen is already very small and that native CraftOS programs will never support window resizing.

Here's a screenshot of the startup screen. If you click the white bar at the top, it will switch the active process to the KAOS System Service.
Spoiler

Here's the KAOS System Service. When processes crash, error messages will be posted here. Clicking the white bar again will spawn a new shell process.
Spoiler

Holding Ctrl+T will no longer send a terminate event. Instead, it will launch the Task Manager. "Switch To" will switch to the selected process. "Kill" will end a process. "Terminate" will send a classic terminate event, which is useful for shells running CraftOS programs that won't close. "Cancel" will switch back to the previous process. KAOS has a hard limit of 256 processes, but I didn't implement a scroll bar in the Task Manager yet, so managing them might prove difficult at the moment.
Spoiler

If the shell is closed by a terminate event, it is currently considered a crash because it ends the process with a call to error().
Spoiler

Here's a demo of a shell running the paint program, because why not:
Spoiler

To install KAOS, run the following. Be aware that it will replace your startup script.
pastebin run s7itaxPE

If you are interested in how KAOS-aware processes work, I suggest taking a peek at the included programs (in /kaos/programs and /kaos/system) and perhaps even the kernel, if you're feeling brave.

That's it for the initial pre-release. I hope someone will find a use for it. I will probably continue to work on it, so all feedback is appreciated.
Edited on 14 February 2014 - 01:42 PM
Lyqyd #2
Posted 14 February 2014 - 01:13 PM
With the upcoming changes in the 1.6 beta, it may no longer be accurate to say that CraftOS programs will never support window resizing. :P/>
Kieran #3
Posted 14 February 2014 - 01:22 PM
Yes, well, true. This whole thing may very well become obsolete quite soon. Perhaps I would have been less motivated to work on it if I had kept up to date on CC news. <_</> Ah well, at least it was a good Lua exercise. As I said, I will keep working on this for a little while, at least, and then I'll re-evaluate when the CC update goes mainstream.
Lyqyd #4
Posted 14 February 2014 - 02:54 PM
Personal edification and enjoyment is the whole point though! If you enjoyed making it, it was worth it.
Kieran #5
Posted 17 February 2014 - 10:16 AM
Minor update to fix a few bugs:
  • Attempting to write outside the lower boundary of sandboxed term would cause a crash. The default edit tool attempts to write to x = 0 when scrolling horizontally.
  • terminate events wouldn't get sent when os.pullEvent was called with a filter parameter.
KaoS #6
Posted 25 February 2014 - 09:09 AM
Even less new than you could've possibly imagined *cough* KaoShell has been around forever
oeed #7
Posted 26 February 2014 - 09:51 AM
Nice job.

Although, you're really not doing the best job at marketing your OS…
apemanzilla #8
Posted 07 March 2014 - 10:06 PM
Well, if it's any consolation, the source code helped me out a bit :3