2
$\begingroup$

By that, I don't mean what is needed to make an operating system. I know that OSes are built on top of kernels and whatnot. But what I mean is, it wasn't like anyone could just "program" the OS like any other software, right? Was an assembler first built? and then a C compiler on top of that? It's a chicken-egg problem I can't seem to find the answer to.

$\endgroup$
2
3
$\begingroup$

There is some great mysticism around Operating Systems. They are sometimes treated like this dark wizardry that only a handful of the initiated are allowed to understand. (Compilers are treated like that as well.)

Here's the truth, though: an Operating System processes inputs and does something in reaction to those inputs. You know what also does that? Every other program.

An OS is just a program. There is nothing special or magical about it.

But what I mean is, it wasn't like anyone could just "program" the OS like any other software, right?

Why not?

Linux was literally written by accident.

Linus Torvalds saved up to buy his dream machine, the pinnacle of computing at the time: a 32 bit 80386 PC clone. And he wanted to learn how to program the 80386 to get the most performance out of it. He spent a lot of time using a terminal program to connect remotely to the university, but all terminal programs that existed where too slow or too clunky.

So, he decided to kill two birds with one stone and teach himself 80386 assembly by writing a better terminal program. After a while, he realized that if he wanted to really dive into how the 80386 works and wanted the most performance, he should get rid of the Operating System and just boot into his terminal program directly. So, he wrote a boot loader that booted directly into the terminal program. Now, without the OS, he also needed a keyboard driver, so he could type commands into the terminal program, he needed a console driver so that the terminal could print answers back, and he needed a driver for the serial port, so he could connect to the university. Unfortunately, when he wanted to transfer files, he still had to boot into the OS, so he added a hard disk driver and a file system driver to the terminal program. And in order to be able to use the terminal program while it was downloading files, he added multithreading and a scheduler.

It was at this point, that he realized, that he had accidentally written an almost complete Operating System. So, he decided to further play around with it, add some missing features, etc.

Then, one day, he mistyped a command, and accidentally overwrote the partition with his Minix installation, thus destroying the existing OS that was installed on the PC.

Now, he had a decision to make: reinstall Minix or finish his OS. And the rest, as they say, is history.

So, writing an OS is really not that different from writing any other kind of program. Linux is the existence proof of that, because it is just a normal program that accidentally became an OS.

$\endgroup$
1
  • 1
    $\begingroup$ One step you don't mention, which OP seems confused on, is that you can directly program a computer using machine code. You don't need anything else, you can write a program directly. $\endgroup$ Nov 1 '20 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.