Mjiig
Posts: 21
Joined: Mon Dec 05, 2011 8:44 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 8:52 pm

Not sure if anyone's already suggested this, I did search but my google fu has never been great.
This was the first thing that occured to me for the Raspberry Pi after I got over the initial OMG IT'S A £20 COMPUTER. The inner workings of any operating system are intrinsically beyond most people because of the enormous complexity of supporting lots of hardware and doing complex things that kernels and things have to do :). It would seem that a very simple piece of hardware, that has only 2 (current) possible configurations and only a few components would be the ideal place to teach anyone who wanted to know how OSs work in the best possible way - making one from scratch. I don't know if this is really feasible but it seems like it ought to be reasonable to build something very simple with minimal features and no GUI or anything in C.
I'd be fascinated personally to see it, and would love to learn about the topic or help out in any way I can.
Thanks for listening to my insane ideas.
Angus

User avatar
Montekuri
Posts: 449
Joined: Thu Sep 22, 2011 6:26 pm
Contact: Website

Re: Simple OS from scratch

Mon Dec 05, 2011 9:03 pm

They tought about An OS for the R-Pi created completely in assembly

joep
Posts: 17
Joined: Sat Nov 26, 2011 4:27 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 9:12 pm

MINIX is a highly modular, message passage OS written entirely in C to teach operating systems principles (and, btw, the inspiration for linux), so it might be of interest to some people here.

http://www.minix3.org/

Mjiig
Posts: 21
Joined: Mon Dec 05, 2011 8:44 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 9:15 pm

Haven't read that entire thread, and it seems very interesting, but assembly is hardly the best language in which to demonstrate how something works. It's an interesting idea though...

User avatar
Montekuri
Posts: 449
Joined: Thu Sep 22, 2011 6:26 pm
Contact: Website

Re: Simple OS from scratch

Mon Dec 05, 2011 9:20 pm

Quote from joep on December 5, 2011, 21:12
MINIX is a highly modular, message passage OS written entirely in C to teach operating systems principles (and, btw, the inspiration for linux), so it might be of interest to some people here.
http://www.minix3.org/
Oh, yes! They talked about MINIX 3 on the Raspberry PI!, too.
And about the Smallest Linux Install

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 9:20 pm

Quote from Mjiig on December 5, 2011, 21:15
Haven't read that entire thread, and it seems very interesting, but assembly is hardly the best language in which to demonstrate how something works. It's an interesting idea though...
There are certain aspects of an OS which cannot be done without resorting to assembly. Indeed, for some concepts, assembly is the only way to demonstrate how it works. Admittedly, these are small edge cases. Anyway.

*coff* http://www.raspberrypi.org/for.....8;t=1417.0 and https://gitorious.org/lambdapi *coff*

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: Simple OS from scratch

Mon Dec 05, 2011 10:28 pm

The device is not simple. Its quite complex. It has a low number of components in order to keep costs down.
I would take a look at http://www.amazon.com/Structur.....0130959901 if you want to understand how computers & OS work.

There is nothing intrinsically hard about an operating system, the book should cover the concepts well (my copy is an older revision) and give you a logical view of the 'components'.

It would be very hard for you to build anything from scratch using any modern processor.

What you could do though is get an RPI, load Linux, fire up your C compiler and make a pseudo OS. That is how I was taught. Write a C program to create a set of processes and semaphores and then schedule those processes according to your pseudo OS's desire (use the semaphore to sleep/wake the process rather than sleep).
The rest of Linux will be running but who cares? You could have your processes write some kind of output and see what happens when you change the scheduling algorithm or start communicating between processes, creating deadlocks etc.

If you want to learn about drivers then you could try making a simple uinput driver, turn some hardware signal into a keyboard event. Probably the simplest driver to create.

PS Usually assembler starts up the hardware, memory controllers etc. Not sure I would call that OS, more like BIOS.

joep
Posts: 17
Joined: Sat Nov 26, 2011 4:27 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 10:38 pm

Oh, yes! They talked about MINIX 3 on the Raspberry PI!, too.

I actually ported MINIX to the Macintosh back in the 90s sometime (it was called MacMINIX). I've been thinking about doing it again ever since I read about the RPi. I suspect the only real obstacle is waiting for all the technical information that will be needed to do it, although some of it could probably be gleaned from the linux implementation I suppose.

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: Simple OS from scratch

Mon Dec 05, 2011 10:49 pm

There may be difficulty in getting some of the information, GPU especially.
Be careful how you ask!

Keith David Smeltz
Posts: 1
Joined: Mon Dec 05, 2011 10:51 pm
Contact: Website

Re: Simple OS from scratch

Mon Dec 05, 2011 11:14 pm

Quote from Mjiig on December 5, 2011, 20:52
It would seem that a very simple piece of hardware, that has only 2 (current) possible configurations and only a few components would be the ideal place to teach anyone who wanted to know how OSs work in the best possible way - making one from scratch. I don't know if this is really feasible but it seems like it ought to be reasonable to build something very simple with minimal features and no GUI or anything in C.
I'd be fascinated personally to see it, and would love to learn about the topic or help out in any way I can.
Thanks for listening to my insane ideas.
Angus

OS Dev is the first thing I thought of, as well, and it's the first thing I'll be using mine for when it arrives. We should maybe collaborate! https://plus.google.com/103214295119897715306/posts or https://twitter.com/#!/KeithSmeltz are good ways to communicate, but how do you prefer to stay in touch?

tufty: Thanks for the https://gitorious.org/lambdapi link, it looks brilliant! One of my favorite languages, too.

Montekuri: Thanks for the http://www.raspberrypi.org/for.....38;t=709.0 and I'll be getting seriously into that as well.

obarthelemy
Posts: 1407
Joined: Tue Aug 09, 2011 10:53 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 11:26 pm

We should set up some kind of competition about who can make the mallest, meanest kernel with the most features ^^

kienly
Posts: 1
Joined: Mon Dec 05, 2011 11:33 pm

Re: Simple OS from scratch

Mon Dec 05, 2011 11:37 pm

How about porting FreeRTOS. It's been ported to many ARM processors.

updatelee
Posts: 11
Joined: Wed Sep 14, 2011 6:04 am
Contact: Website

Re: Simple OS from scratch

Tue Dec 06, 2011 3:08 pm

You could, linus did.

but why bother, depending on your application there are lots of excellent highly refined OS's out there already.

Mjiig
Posts: 21
Joined: Mon Dec 05, 2011 8:44 pm

Re: Simple OS from scratch

Tue Dec 06, 2011 6:33 pm

Quote from updatelee on December 6, 2011, 15:08
You could, linus did.

but why bother, depending on your application there are lots of excellent highly refined OS's out there already.

Because life is more fun when you understand things.

adric22
Posts: 10
Joined: Wed Oct 19, 2011 3:24 pm

Re: Simple OS from scratch

Tue Dec 06, 2011 8:00 pm

With a proprietary operating system written in assembler, the Raspberry Pi would be ridiculously fast. I'm willing to bet somebody could write a very minimal text-based operating system in under 8K. You could probably do something with a minimal GUI for around 32K or 64K.

The problem is with making anything from scratch is that if you want to be able to do useful things like connect to the internet, support for USB devices, etc... there are so many different layers that have to be accounted for. It would be a monumental task.

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: Simple OS from scratch

Tue Dec 06, 2011 8:10 pm

Quote from obarthelemy on December 5, 2011, 23:26
We should set up some kind of competition about who can make the mallest, meanest kernel with the most features ^^

You could challenge people 'mine's smaller than yours...' ;)

Arreladd
Posts: 10
Joined: Mon Aug 22, 2011 8:06 pm

Re: Simple OS from scratch

Wed Dec 07, 2011 5:54 am

If your up to it I wouldn't mind taking part in this kind of project.

ChrisR
Posts: 14
Joined: Tue Dec 06, 2011 3:11 pm

Re: Simple OS from scratch

Wed Dec 07, 2011 8:10 am

It's pretty simple to get something going, but don't underestimate just how much software is required for what is considered basic functionality nowadays. Writing a kernel is certainly complex, but it tends to be a tiny amount of code compared to everything else.

As a learning exercise it's a fantastic idea. Just make sure everything is well documented and you might even be able to turn it into a basic OS design course for interested teenagers.

Mjiig
Posts: 21
Joined: Mon Dec 05, 2011 8:44 pm

Re: Simple OS from scratch

Wed Dec 07, 2011 8:26 am

Quote from ChrisR on December 7, 2011, 08:10
It's pretty simple to get something going, but don't underestimate just how much software is required for what is considered basic functionality nowadays. Writing a kernel is certainly complex, but it tends to be a tiny amount of code compared to everything else.

As a learning exercise it's a fantastic idea. Just make sure everything is well documented and you might even be able to turn it into a basic OS design course for interested teenagers.


That's the basic idea, I do appreciate that it would remain complex, but it's still going to be easier that building an operating system for any other modern computer because it has so few less things to account for. The purpose isn't really to create an operating system that's ideal for day to day use but to create an operating system so simple that someone with little prior experience in how operating systems work could understand it.
Angus

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Simple OS from scratch

Wed Dec 07, 2011 9:51 am

Quote from ChrisR on December 7, 2011, 08:10
As a learning exercise it's a fantastic idea. Just make sure everything is well documented and you might even be able to turn it into a basic OS design course for interested teenagers.

I'm doing just that.

http://stm8sdiscovery.blogspot.....-part.html

ProDigit
Posts: 376
Joined: Tue Aug 30, 2011 1:24 am

Re: Simple OS from scratch

Wed Dec 07, 2011 10:03 am

Problem with most small OS-es that are text based, is that they are single threaded. Meaning, it's pretty hard to run 2 tasks at the same time (eg: do a virus scan, while copying files, while browsing, while also having an openoffice document opened)!

Plus, to browse online, you need some form of GUI. I don't believe there are many internet browsers for text based OS'es!

ChrisR
Posts: 14
Joined: Tue Dec 06, 2011 3:11 pm

Re: Simple OS from scratch

Wed Dec 07, 2011 10:08 am

Nice one :) Remember when you turn the MMU on, your existing memory will be inaccessible until you map it in - you can replace the vector table then if you want to keep your bootloader simple :)

tntexplosivesltd
Posts: 72
Joined: Fri Sep 30, 2011 8:08 am
Contact: Website

Re: Simple OS from scratch

Wed Dec 07, 2011 10:19 am

Quote from ProDigit on December 7, 2011, 10:03
Problem with most small OS-es that are text based, is that they are single threaded. Meaning, it's pretty hard to run 2 tasks at the same time (eg: do a virus scan, while copying files, while browsing, while also having an openoffice document opened)!

Plus, to browse online, you need some form of GUI. I don't believe there are many internet browsers for text based OS'es!


No, they are in no way single-threaded.
Linux (not talking about anything to do with X here) solved the multithreading with forking processes to the background, and the multiple login terminals (tty1-tty6)

Or by multithreading do you mean multitasking?

There are a few text-based browsers (e.g. Links - I use it myself at times) but I agree that a GUI is needed for a browser. But for a headless machine (e.g. using the machine as a server), you don't need a browser =P

adric22
Posts: 10
Joined: Wed Oct 19, 2011 3:24 pm

Re: Simple OS from scratch

Thu Dec 08, 2011 1:31 am

The best bet would be to take an absolute minimal linux kernel compiled with all of the drivers that the Raspberry Pi uses, leaving everything else out. Leave out a lot of the legacy unix stuff. Then build a new GUI that is not based on X in any way. Sort of like MacOS X, BeOS, AtheOS, etc. (yes, I realize the last two are not Linux, but they are POSIX compliant with proprietary GUI)

It would be wicked fast and use very little RAM.

Bakul Shah
Posts: 324
Joined: Sun Sep 25, 2011 1:25 am

Re: Simple OS from scratch

Thu Dec 08, 2011 4:28 am

Check out the osdev.org site. Projects, forum, FAQ, etc. Lots of good stuff!

Also worth checking out: Lions' commentary on 6th Edition Unix -- it describes a much simpler Unix and should give you a good idea about os components. It was written when a Unix kernel used to fit in under 64KiloBytes -- these days some *header* files are larger than that!

As for actually writing an OS from scratch qemu makes your job really easy (very quick code,compile,load,test,debug cycle). Pick an emulated processor the same as (or close to) the real processor you are planning to use. Once you have serial IO working, you can take it "live" for reality check but it will be faster to stick with qemu for quite a while.

Return to “Other projects”