Jump to content

  • Log In with Google      Sign In   
  • Create Account


Create an operating system


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
40 replies to this topic

#1 Bentm's Games   Members   -  Reputation: 88

Like
-1Likes
Like

Posted 26 October 2012 - 08:07 PM

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:


Edited by Bentm's Games, 28 October 2012 - 10:25 AM.


Sponsor:

#2 nife87   Members   -  Reputation: 516

Like
7Likes
Like

Posted 26 October 2012 - 10:19 PM

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.

#3 ATC   Members   -  Reputation: 551

Like
18Likes
Like

Posted 26 October 2012 - 10:58 PM

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:

A) You already have experience and know how to write an OS

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--

Edited by ATC, 29 October 2012 - 03:15 PM.

_______________________________________________________________________________
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!
___________________________________________________________________________________

#4 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 27 October 2012 - 12:48 AM

...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.

Edited by Narf the Mouse, 27 October 2012 - 12:50 AM.


#5 joew   Crossbones+   -  Reputation: 3556

Like
4Likes
Like

Posted 27 October 2012 - 12:53 AM

...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!

Edited by joew, 27 October 2012 - 12:53 AM.


#6 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 27 October 2012 - 01:20 AM


...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!

*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? :)

Edited by Narf the Mouse, 27 October 2012 - 01:20 AM.


#7 Washu   Senior Moderators   -  Reputation: 4493

Like
7Likes
Like

Posted 27 October 2012 - 02:24 AM

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.

Edited by Washu, 27 October 2012 - 02:24 AM.

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.
ScapeCode - Blog | SlimDX


#8 Ryan_001   Prime Members   -  Reputation: 1233

Like
0Likes
Like

Posted 27 October 2012 - 03:00 AM

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.

#9 TheVirtualDragon   Members   -  Reputation: 237

Like
4Likes
Like

Posted 27 October 2012 - 05:53 AM

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.

#10 mrbastard   Members   -  Reputation: 1573

Like
0Likes
Like

Posted 27 October 2012 - 06:47 AM

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:

A) You already have experience and know how to write an OS

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?


#11 SelethD   Members   -  Reputation: 381

Like
2Likes
Like

Posted 27 October 2012 - 07:09 AM

Perhaps I am off track, but from what I understood of the OP, is that he/she is wanting to know of some type of 'graphical' tools such as flash, to create the prototype. I dont think the OP is actually interested in 'coding' anything.
At least thats what I read into it. Although, I'm glad some good book titles were posted on the subject. I haven't done assm in a long long time, but reserch into writing a tiny os looks to be some interesting reading.

#12 Telcontar   Members   -  Reputation: 868

Like
3Likes
Like

Posted 27 October 2012 - 07:49 AM

Just reading ATC's response scared the everliving shit out of me, and I was not (and never would) consider trying to build a new OS.

Well, I'm off to have nightmares of implementing malloc and free...

I Create Games to Help Tell Stories | Writing Blog


#13 Bentm's Games   Members   -  Reputation: 88

Like
0Likes
Like

Posted 27 October 2012 - 08:11 AM

Perhaps I am off track, but from what I understood of the OP, is that he/she is wanting to know of some type of 'graphical' tools such as flash, to create the prototype. I dont think the OP is actually interested in 'coding' anything.
At least thats what I read into it. Although, I'm glad some good book titles were posted on the subject. I haven't done assm in a long long time, but reserch into writing a tiny os looks to be some interesting reading.

Pretty much. What I want to do is create a sort of program that would act like the os. Then build and build and build on that. Then maybe make a virtual os. Once I would get more people working, I would eventually build a linux window manager, then after years (but probly not) possibly maybe consider consider consider maybe wantin to consider to almost amybe feel like considering to want to make a full fledged os. What I want to know is what program to use to make this program, and tutorials for it.

#14 Pointer2APointer   Members   -  Reputation: 283

Like
0Likes
Like

Posted 27 October 2012 - 02:19 PM

It's much easier to make a program act as if it were a real operating system (to some sort) than an actual operating system(and a lot more bearable as well).

And I don't think your terminology of "virtual" to "real" operating systems makes sense.

An operating system running on a virtual machine is still a "real" operating system, as it would generally carry the same instructions that would be used otherwise on real hardware directly, rather than a program acting like a virtualized version of real hardware itself.

And if you're really that eager to see how they made the video, contact them on their YouTube account.

Someone else can propose an idea, guess, or maybe know, but it's hard to tell based on just a video as to what program was used to make it.

If you want to make an operating system for real, however, you have a lot of learning to do.

Even though an operating system is still software, it's not the same as compile-and-go "Hello world!" that can be accomplished and executed in less than a minute from scratch(with the right programs, input speed, files and knowledge ready).
Yes, this is red text.

#15 Bentm's Games   Members   -  Reputation: 88

Like
0Likes
Like

Posted 27 October 2012 - 02:34 PM

It's much easier to make a program act as if it were a real operating system (to some sort) than an actual operating system(and a lot more bearable as well).

And I don't think your terminology of "virtual" to "real" operating systems makes sense.

An operating system running on a virtual machine is still a "real" operating system, as it would generally carry the same instructions that would be used otherwise on real hardware directly, rather than a program acting like a virtualized version of real hardware itself.


That's what I want to do, create a program that would act as an interface. And by virtual, I mean something like what people make in vbs and call an os

#16 ATC   Members   -  Reputation: 551

Like
0Likes
Like

Posted 27 October 2012 - 03:21 PM

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.


Yes, sorry, I screwed up my code... The original version I wanted to post from one of my first working OS kernels is this:

char* screen = (char *) 0xB8000;

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

for( int index = 0; str[index] != '\0'; ++index)
screen[index] = str[index];

EDIT: I figured out why my code was getting screwed up... if you're using a variable named "i" as an array index the forums interprets it as italics lol! So now I fixed it so the code is correct. Posted Image

However, when I tried to post it with the code/source tags it came out screwed up and was unreadable (for some reason the forums don't like array indexing [x] symbols in code/source tags)! So I tried to modify it to make it readable using just pointer arithmetic but it looks like I actually just [i]screwed it up (never incremented "screen" so, you're right) lol. I will fix the original example; thanks for pointing it out! Was very tired last night! Posted Image

And yes, you're right... it is real-mode. Sorry for that mix-up too! But I was simply demonstrating how physical RAM can be manipulated in Ring-0 without causing a crash, and how to make a basic "Hello world" kernel work. You obviously wouldn't want to use this code in a real/practical OS project. It's just a contrived example to make a point. ;)

Edited by ATC, 27 October 2012 - 03:28 PM.

_______________________________________________________________________________
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!
___________________________________________________________________________________

#17 Washu   Senior Moderators   -  Reputation: 4493

Like
2Likes
Like

Posted 27 October 2012 - 03:39 PM


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.


Yes, sorry, I screwed up my code... The original version I wanted to post from one of my first working OS kernels is this:

char* screen = (char *) 0xB8000;

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

for( int index = 0; str[index] != '\0'; ++index)
screen[index] = str[index];

EDIT: I figured out why my code was getting screwed up... if you're using a variable named "i" as an array index the forums interprets it as italics lol! So now I fixed it so the code is correct. Posted Image

However, when I tried to post it with the code/source tags it came out screwed up and was unreadable (for some reason the forums don't like array indexing [x] symbols in code/source tags)! So I tried to modify it to make it readable using just pointer arithmetic but it looks like I actually just [i]screwed it up (never incremented "screen" so, you're right) lol. I will fix the original example; thanks for pointing it out! Was very tired last night! Posted Image

And yes, you're right... it is real-mode. Sorry for that mix-up too! But I was simply demonstrating how physical RAM can be manipulated in Ring-0 without causing a crash, and how to make a basic "Hello world" kernel work. You obviously wouldn't want to use this code in a real/practical OS project. It's just a contrived example to make a point. ;)

Well, the bad news is, that code is STILL wrong.

The text screen video memory at that address takes WORDS, not bytes. Each word is a combination of a character to display and an attribute describing the color of the character and its background.

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.
ScapeCode - Blog | SlimDX


#18 ATC   Members   -  Reputation: 551

Like
2Likes
Like

Posted 27 October 2012 - 03:49 PM

Well, the bad news is, that code is STILL wrong.
The text screen video memory at that address takes WORDS, not bytes. Each word is a combination of a character to display and an attribute describing the color of the character and its background.


Ah, got me again... Oddly though, using char* did work, but in the real code I was padding it with the color information to write 16-bits for each char... But I looked at my text I/O implementation of a more mature version of my system project and saw that I actually used type unsigned short*, so you're correct. It's been a couple years though, like I said... so my memory of some things is a bit faded. Posted Image

Anyhow... about learning resources... It is indeed true that there are plenty books on OS development. But very few (in my experience) were suitable for beginners and even fewer actually teach how to write your first OS. Most books assume you're a CS major with system's programming experience and teach about OS design/architecture as opposed to the "how" and "why". So as a beginner OS programmer it's extremely difficult to find the learning resources you need. It's been a couple years since I did my OS project, so maybe things have changed; but that is the way I remember it.

Just reading ATC's response scared the everliving shit out of me, and I was not (and never would) consider trying to build a new OS.

Well, I'm off to have nightmares of implementing malloc and free...


Well, I didn't mean to scare ya lol! Posted Image

It's actually a lot of fun... and the feeling of overwhelming satisfaction you get from making the damn thing work for the first time was one of the most rewarding programming experiences I've ever had. Writing you own CSTDLib functions like malloc and free is also extremely rewarding. It's difficult and frustrating to get through it but when you get it working correctly you will be extremely happy and proud of yourself. Each time you call malloc or free you'll be grinning ear to ear knowing you made that code work. :-)

Even the little things like rolling your own strlen or strcmp functions are fun:

[source lang="cpp"]// Naive approach; just an example ::size_t strlen( const char* str ) { size_t len; char* ptr = (char *)str; for( len = 0x00; *ptr != '\0'; ++ptr, ++len ) ; return len;}[/source]

Seriously, you should try your hand at it! It's really challenging and entertaining to roll your own standard lib and try to write optimal routines and functions. And you'll walk away knowing 1000 fold more about C, C++, assembly language, the standard libraries and computer science.

One thing that was unique about my OS project is that I developed it completely within Visual Studio 2008 (Pro). Yes, you can indeed write an OS in Visual Studio! It's all about configuring the environment and project settings correctly, and either writing your own bootloader capable of handling your kernel/loader or implementing the multi-boot standard to make your OS interoperable with a good bootloader like GRUB.

I chose the latter approach, and used GRUB. And my kernel was actually a PE image (.exe file). The way I achieved interoperability with GRUB was by setting the base address of the PE image to the system loader's entry point, and using some assembly language tricks to emit the multi-boot header right there where GRUB would be expecting it. For example:

[source lang="cpp"]#define dd(x) \ __asm _emit (x) & 0xff \ __asm _emit (x) >> 8 & 0xff \ __asm _emit (x) >> 16 & 0xff \ __asm _emit (x) >> 24 & 0xff[/source]

That macro will actually embed a dword right into the code. So you can do this:

[source lang="cpp"]int _loaderMain( ){ dd( MB_MAGIC_NUMBER ); // ... and so on ...}[/source]

I also went so far as to write an entire static lib for handling PE images and reading their headers which could be linked right into the kernel or anything else that needed it. I implemented drivers as DLLs with a special *.DRV extension, and the OS loader (an intermediate loading program loaded by the bootloader that loaded the kernel and critical drivers) could us the "PELib" to read the kernel and driver headers. Just talking about it kinda makes me want to start playing with it all again, but I've got an engine to write lol. Posted Image

Regards,

--ATC--

Edited by ATC, 27 October 2012 - 03:54 PM.

_______________________________________________________________________________
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!
___________________________________________________________________________________

#19 ATC   Members   -  Reputation: 551

Like
2Likes
Like

Posted 27 October 2012 - 04:07 PM

To demonstrate what Washu is talking about, a correct example of what I was trying to demonstrate earlier would be more like this::

[source lang="cpp"]void _writeText( const char* str ) { int index = 0x00; char* pstr = (char *)str; unsigned short *vidMem = (unsigned short *)0xB8000; for( ; *pstr; ++pstr, ++index ) { unsigned char c = *pstr; vidMem[index] = (unsigned short) c | 0x0700; }}[/source]

Sorry for screwing this up multiple times trying to make a simple point lol... Like I said, it's been years and I can't copy code from any of my projects verbatim because there's a lot of code, headers, macros and functions used in numerous files and it wouldn't make sense without posting it all (overkill for such a small, contrived example). So I just have to either try to strike up examples from memory or write a new, simplified version; as it so happened I did that wrong, lol... :P

Hopefully this time I did the demonstration correctly haha
_______________________________________________________________________________
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!
___________________________________________________________________________________

#20 Bentm's Games   Members   -  Reputation: 88

Like
2Likes
Like

Posted 27 October 2012 - 04:26 PM

To demonstrate what Washu is talking about, a correct example of what I was trying to demonstrate earlier would be more like this::

[source lang="cpp"]void _writeText( const char* str ) { int index = 0x00; char* pstr = (char *)str; unsigned short *vidMem = (unsigned short *)0xB8000; for( ; *pstr; ++pstr, ++index ) { unsigned char c = *pstr; vidMem[index] = (unsigned short) c | 0x0700; }}[/source]

Sorry for screwing this up multiple times trying to make a simple point lol... Like I said, it's been years and I can't copy code from any of my projects verbatim because there's a lot of code, headers, macros and functions used in numerous files and it wouldn't make sense without posting it all (overkill for such a small, contrived example). So I just have to either try to strike up examples from memory or write a new, simplified version; as it so happened I did that wrong, lol... Posted Image

Hopefully this time I did the demonstration correctly haha

Guys, guys, guys. Calm down. I dont need this info (but thanks and you are some smart peeps) all i need to know is how to make a program that i could add buttons animations and interactive objects into so it will give the illusion of being an os. I need this to test usability, and help my ability in coding and other software. So far REAL studio seems like my best bet, any suggestions




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS