Create an operating system

Started by
39 comments, last by ATC 11 years, 5 months ago
Herro. Im not sure if this fits in programming, but i have a question. I had a mind-blowing dream for an operating system last month, and i need to make a prototype. How would I go about doing that. Would i use flash or vbs or what? I would make a prototype like this guy:

[media]
[/media]
Advertisement
So you want to make a prototype of the GUI, not the actual OS, right?
I see no reason why the interface shown in the video is not just another fancy GUI (probably for mobile units) with network connection and a database of your media attached, but I might have missed something?
For the GUI, yes, you can use pretty much any language, including the now out-dated flash and the newer HTML 5. But you can use pretty much anything that enables you to make a graphical and relational mock-up quickly. So if you already know a language/technology or two, I would certainly investigate if you can use that instead of learning a new one.
As someone who's actually written a working OS before, I would recommend you don't even waste your time making this GUI "prototype" unless:

[indent=1]A) You already have experience and know how to write an OS
[indent=1]B) You have not completed A, so you stop what you're doing to complete A... lol

Writing an operating system is one of the most difficult programming tasks you could ever hope to do. But I do think you should do it! Not only is it fun but the things you will learn from it will make you twice the programmer you were before. It's an "academic" project I think every serious programmer should try. You're going to need intimate knowledge of not only C and C++ but also assembly language for the processor(s) you are targeting/supporting. Apart from that you need an extremely thorough understanding of memory and how the hardware you're targeting works. After all, you're programming not in "userland" but in Ring-0, where you have direct access to physical RAM and hardware.

When I say "direct access to physical memory" I mean that literally. For example, on x86 architecture when an OS is running in PMode (protected, 32-bit memory mode) with video memory in color text mode, the contents of video memory are in the address range 0x000B8000 to 0x000BFFFF. Want to write to video memory directly?

[source lang="cpp"]
unsigned short* screen = (unsigned short *) 0xB8000;

const char* str = "Hello, OS world!\0";
char* pstr = (char *)str;

for( ; *pstr != '\0'; ++pstr, ++screen)
*screen = (unsigned short) (*pstr | 0x0700);
[/source]

That's right... In Ring-0 you can cast any arbitrary unsigned integer into a pointer type and just directly read/write RAM. While this is extremely powerful, it can also be very "dangerous". If you don't know what you're writing where you could be corrupting important data or destroying bits of your kernel or critical system drivers in memory lol. So to develop any somewhat sophisticated operating system you'll need to implement a full-blown memory manager and implement a virtual memory. Hopefully that gives you an idea of how hard this is lol...

You're going to need to know pretty much everything about your CPU and hardware and how it all works to get anything done. For instance, do you know the significance of the address 0x007C00 on x86 architecture (place where BIOS loads bootloader)? There are tons of little ins and outs like that you must learn, and it takes a LOT of freakin time. Expect to be working on just getting a good bootloader and basic kernel started for several months if you're a beginner to OS programming. Your non-OS-related programming experience will be very helpful but cannot prepare you for what you're about to face. For example, you'll have to start coding your OS in C or assembly language. You cannot use C++ because you have no C++ runtime environment and no implementation of important language constructs like the new and delete operators. But oh wait, when you write your C code you can't use any of the C Standard Library because your OS doesn't have a CSTDLib yet! You've gotta write your own, complete with your own malloc and free implementations! :-)

So hopefully that makes it clear why I suggest you start learning OS programming instead of fooling around with a useless FLASH prototype that doesn't help you on your quest one bit. Worry about that prototype when you've got a good OS framework written and know what you're doing. Implementing good graphics and a GUI shell in your OS is an extremely advanced topic, and you will have had to write your own input drivers for mouse, keyboard, etc for it to be of any use... yes, that's another thing, you've gotta write your own drivers... you have to write everything yourself because a new OS project is a completely blank slate! XD

The quest you're about to embark upon is incredibly fun, as scary as my little speech might make it sound. And along the way it also gets very frustrating because there are virtually no resources available online or in book stores to help you. But I am here if you need some help. I'm not (by any means) a professional OS developer, but I know quite a bit about it from my past experience. I can provide you with learning resources and help coding (I've got some of my source saved on a USB flash drive). So feel free to pm me if you need any assistance. It's a topic I enjoy discussing because it's so "low-level" and intriguing!

Regards,

--ATC--
_______________________________________________________________________________
CEO & Lead Developer at ATCWARE™
"Project X-1"; a 100% managed, platform-agnostic game & simulation engine

Please visit our new forums and help us test them and break the ice!
___________________________________________________________________________________
...Y'know, I'd be interested in buying a good book on writing an OS, if anyone wants to write one and put it up on Amazon. I'd probably learn a lot from it, if nothing else.

...Not that writing a textbook isn't a massive project.

...Y'know, I'd be interested in buying a good book on writing an OS, if anyone wants to write one and put it up on Amazon.

You mean like Tenenbaum's books Modern Operating Systems and Operating Systems Design & Implementation? Or something more like Design of the UNIX Operating System? There are literally tons of them on Amazon!

[quote name='Narf the Mouse' timestamp='1351320533' post='4994357']
...Y'know, I'd be interested in buying a good book on writing an OS, if anyone wants to write one and put it up on Amazon.

You mean like Tenenbaum's books Modern Operating Systems and Operating Systems Design & Implementation? Or something more like Design of the UNIX Operating System? There are literally tons of them on Amazon!
[/quote]

*Snip*

And along the way it also gets very frustrating because there are virtually no resources available online or in book stores to help you.

*Snip*

Regards,

--ATC--

...Alright, which one of you is right? :)

When I say "direct access to physical memory" I mean that literally. For example, on x86 architecture when an OS is running in PMode (protected, 32-bit memory mode) with video memory in color text mode, the contents of video memory are in the address range 0x000B8000 to 0x000BFFFF. Want to write to video memory directly?

[source lang="cpp"]
char* screen = (char *) 0xB8000;

const char* str = "Hello, OS world!\0";
char* pstr = (char *)str;

for( ; *pstr != '\0'; ++pstr)
*screen = *pstr;
[/source]

Actually, that address is a holdover of realmode, not protected mode. While still mapped (up to a point) when you switch to protected mode, it does not need to, nor usually will, remain mapped to that address range. Furthermore, if you have enabled paging then that code could be doing all sorts of nasty things to the byte at 0xB8000. Additionally, your code only affects a single byte of memory, and thus doesn't actually print your string so much as it puts '!' to the byte at address 0xB8000.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

I wrote a small OS for a university project, even wrote the boot loader from scratch in assembly and did the rest in C++. Its not easy at all. When things go wrong you don't get a pretty screen with debug info, you get a 3 beeps and re-start and its back to scratching your head over the assembly trying to figure what went wrong. Also working with BIOS is an archaic and esoteric art in and of itself, with sparse documentation hidden in obscure areas of the interwebs. Though it is a learning experience, and one day I will revisit it and finish what I started ;) Good luck to you.
Creating an OS is one of the hardest things ever.
However, if you want to create just a GUI, then pick a pre-existing OS - like a Linux distro - and write the GUI in something like C++.

Also, if you are serious about creating an OS, then I suggest you look at this. It is a very useful resource, in my opinion.
What's This?: basically, it's my blog. Click on it.

As someone who's actually written a working OS before, I would recommend you don't even waste your time making this GUI "prototype" unless:

[indent=1]A) You already have experience and know how to write an OS

[indent=1]B) You have not completed A, so you stop what you're doing to complete A... lol


I'd add:

C) You're talking about a GUI setup that could be implemented as a windows manager on linux (for example). This is likely a tractable task for an individual, especially if an existing project is used as a starting point.
D) You feel you'd enjoy building the prototype.
E) By prototype you mean an interactive animation. This seems very clear to me from the OP's comment, but perhaps escaped some of you guys?
[size="1"]

This topic is closed to new replies.

Advertisement