June 14, 2018

Operating systems for homebrew CPUs


With the advent of the internet, a huge amount of websites were created with the topic of self-grown CPU. That are self-made computers in 8 bit, often created by 2000 transistors or less and with the aim to understand fully what computing is. Such projects are going into the details, and are building not only the ALU in hardware, but also the memory and the microcode. A side-discussion on homebrew CPUs is the question under which operating system such a systems can operate. Usually one of the following software is used: Contiki (8-bit TCP/IP system), BASIC (classical 1980s home computer choice) and Forth (stack-based language and operating system).
The general idea behind the software is very equal. The constraint is, that a homebrew cpu has only limited ressources, which means it is a 8 bit cpu or sometimes a 4 bit cpu, with little amount of physical RAM. The idea behind Contiki, BASIC and Forth and is to run under such conditions. At the same time it become obvious what the disadvantages are. For example, the Contiki system is well programmed but compared to a real operating system like Linux or Android it has a lack of feature. That means, it is not possible to run LaTeX under Contiki or use it as video encoder.
The main difference between operating systems for homebrew cpus and their full-blown equivalent is the amount of lines of code. THat means, the Linux kernel needs 100 MB, while contiki is happy with 2 kb. To assume, that Contiki can do everything what the Linux is able to do is wrong. That means, it makes no sense to install Contiki on a standard-pc. Such a system would be inferior to a real Linux server.
The main purpose of homebrew CPUs, BASIC, contiki, Forth and other small sized systems is education. A homebrew CPU together with Forth is usually not created because somebody needs a computer or want's to run software, but because he want's to learn to program a computer and design it from scratch. A 2000 transistor CPU together with Contiki is a training environment to learn and teach certain elements in computing.
A typical example for a BASIC interpreter in homebrew cpus is EhBASIC. It is a modern BASIC os which runs on 6502 like CPUs. The purpose is similar to a Forth system. With EhBASIC the users gets a minimalistic environment in which he can writer further programs. The EhBASIC system has the purpose to demonstrate the working hardware. If the self-made CPUs boots up the basic interpreter and runs a short prime number program, everything works fine.
The most dominant aspect of EhBASIC is, that it can't be extended. THat means, it is not possible to grow the system into a working full-blown operating system by adding some extra sourcecode. It was designed with a special purpose to be a small system. Let us compare EhBASIC with the Android operating system. What is the difference? At first the demand for CPU and RAM ressources is higher on the Android world. And secondly, it is easier to write software for Android, because the operating system has a lot of working APIs for graphic and network interfaces. Somebody who is booting a BASIC interpreter asks perhaps, why Android is so huge. Isn't it possible to write an operating system in under 5 kb? No, it is not. If someone reinvents Android or Linux from scratch he will always get into the same amount of 1 gb of sourcecode (or more) which needs lots of RAM to run.

No comments:

Post a Comment