- Hardware: ComputerCraft really isn't hardware, so this would be any peripherals and the terminal
- Operating system: The operating system manages the hardware, and sets up interfaces for applications to use.
- Applications: The applications run in the environment the Operating system sets up. Depending on how the application is started, the application can have lots of privileges or barely any.
- The user: The user is you. You interface the Operating system via the Applications running in the Operating system. The application sets up its own interface for use you to interact with.
What composes an Operating System?
The Operating system is the main component, and can be divided into subsections:
- Kernel: The kernel is the heart of the operating system. It is responsible for managing hardware, setting up interfaces, and making protected modes for which programs run in. With lua, we have the pcall function. We also have setfenv that can limit the functions in the processes global table.
- Drivers: Drivers are sorta like an api. They manage their specific hardware or hardware set and translate that into something the kernel can use. Which inturn allows the kernel to provide the Application access to that device if the kernel allows.
- Multitasking: First off, multitasking is not needed for the operating system to function. Multitasking allows for multiple programs to run simultaneously, including the kernel. Using coroutines, this can be achieved easily.
- Filesystems: Since in ComputerCraft the diskdrive or fs api doesn't access a random glob of data and translates it into files and folders, this is quite different in handling by the kernel. In ComputerCraft, this is manageing the fs api, making a large file and using that as a partition, or doing both using the large file as an addon to the fs api.
Linux isn't the only Operating System with a kernel:
Linux comes with a kernel sometimes called vmlinux, vmlinuz, uImage, or zImage. It doesn't need to be called this.
Windows 2000+ has ntoskrnl.exe
MSDOS has MSDOS.SYS, which after 7.0 got merged to IO.SYS
FreeDOS has KERNEL.SYS
OS/2 has OS2KRNL
The Windows 9x family had kernels
Windows 3.11 had a kernel.
Not only linux comes with an Operating System kernel.
Some important notes
Security is very important.
Try your best when making one to be sure that the program cannot fool the kernel into getting more access than it should.
Also, making sure that the programs that have access to the filesystem api cannot delete the kernel.
You don't have to be black and white when giving programs access to certain things. It is possible to only give a subsection of an api.
Example of how hardware of the computer gets access via each limited program execution:
The hardware is a screen, the computer itself (lua), a disk drive, and a modem.
The operating system takes over all of the hardware, except it was built without the knowledge of the modem, so it becomes unused.
The operating system runs a program that can only access the screen and the computer, the disk drive and modem are now unused.
The programs makes an interface that only prints one line when you click on a certain area. Now several features of the screen, the disk drive, and modem are unused.