Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Promit

How do you compile an OS?

This topic is 6011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive always been wondering on this. Obviously you cant compile to any sort of stright executable, because the executable format itself is defined by the OS. The compiler needs to support compiling for that OS, so you''ll need a custom compiler and/or linker, won''t you? And then, how do you beta test an OS that doesnt actually do very much yet? I have no experience with systems programming like this, so i was just curious... ----------------------------- The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites
Advertisement
You have to write a bootloader which sits at the beginning of the drive. The bios then loads this code, and starts executing it. Now you''re running your code you can do whatever you want, which generally includes loading your files off disk etc...

How do you beta test? I''m not sure i understand what you mean because you can test at any stage - even when it just prints "Hello World! JxOS Started..." this is testing that you can actually get to that particular stage in the program.

This is a really basic view of it, but i hope you get the idea of how you get control in the first place.

Jx

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You write the OS to be compiled in some already existing OS. Typically the OS is loaded by a simple loading program (This is what linux, windows, etc, do.) This bootloader is the thing that needs to understand the executable format of the OS binary. The technical term for this is bootstrapping. The process to port a compiler onto a type of hardware that''s never had a compiler before is similar.

Linux was first compiled on minix, for example, and required minix to be present to compile properly. Only later was it ''ported'' to itself.

Having an OS or compiler compile itself is considered one of the early hurdles for the project, but it sure doesn''t happen right away.

Share this post


Link to post
Share on other sites
If you get an x86 emulator (bochs for example), you can create
your operating system in windows and create the bootsector
information for your operating system, and test it in windows
in a window(obviously ), that''d save a lot of time and would
be a lot easier. Hope u understand wot i mean, i''m tired
and my english is slowly slipping away, even though i''ve spoken
it for about 15years(1 and 2 don''t count)

Share this post


Link to post
Share on other sites
It's a process of "bootstrapping".

First you need to design an exectuable format.

Then you write a loader on an existing OS (Windows, Linux).

After you're convinced that it works, you write a cross-compiler for your OS. You "simply" have to modify GCC "a little bit" so it outputs your executable format.

Cross-compile your exectuable loader and hope for the best.
The rest is just a matter of writing a complete set of I/O, process scheduling, multithreading... etc routines.

Really, it can be done in maybe 2 years by one person.

Linus Torvalds did it... kind of.


Premature optimizations can only slow down your project even more.

Edited by - tangentz on January 31, 2002 4:40:04 PM

Share this post


Link to post
Share on other sites
quote:
Original post by tangentz
First you need to design an exectuable format.

Then you write a loader on an existing OS (Windows, Linux).

After you''re convinced that it works, you write a cross-compiler for your OS. You "simply" have to modify GCC "a little bit" so it outputs your executable format.


Why?
What''s wrong with ELF or COFF or COM or A.OUT? Unless your OS requires some sort of special features, it''s much easier to stick with an existing file format.

Share this post


Link to post
Share on other sites
Hey, are you kidding Olsueyi??!!! He''s cool (->a bit low-temperatured). Maybe he has a too huge fan.

-Kneelz.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!