Getting Started

From OSDev.wiki
Revision as of 05:53, 31 August 2007 by osdev>Yayyak (→‎Testing your operating system: complete rename/merge)
Jump to navigation Jump to search

Getting motivated

First of all, developing an operating system is probably one of the most challenging things you can do on a computer (next to killing the final boss in Doom on Nightmare difficulty level). Composing an operating system requires a lot of knowledge about several complex areas within computer science. You need to understand how hardware works, be able to read and write the complex Assembly language, and also a higher level language (like for instance C, C++ or Pascal). Your mind has to be able to wrap itself around abstract theory, and hold a myriad of thoughts. Feel discouraged yet? Don't fear! Because all of these things are also the things that makes OS programming fun and entertaining.

There is nothing like the feeling of accomplishment. When you, finally, after hours of struggling finally solve the problem. And after some time you are able to look back and see all of the things you've created from scratch. Your handwritten system is able to boot, performs magic against the hardware, and gives the user a user interface and programs to play with.

There is no absolute path you have to take when creating a OS. Once you get your initial system up and running (and you do this by finding appropriate tutorials), you choose the path you want to take next. Your OS is exactly that - yours. You have ultimate control, and the sky is the limit!


Prerequisites

I'm not going to lie. Operating system development is difficult. But there are a lot of things you can do to make it easier.

  • Assembly: You should have knowledge about the low-level language Assembly. Read a book. Take a course at school. At least read some tutorials, and write some code. You WILL need it.
  • C / C++: Most of the operating systems are written in C (or C++), and a good understanding of this is required.
  • Linux / Unix experience: Even though this is not really required you will soon notice that many of the tools used are developed for Linux, and later ported over to Windows. The Linux kernel is often used as an example, and many of the hobby operating systems have some resemblance to Linux. Having at least installed Linux and played around with the command line will make things easier.
  • Time and motivation :)


Choosing your development environment

You need a platform to develop your system on. The two most common are Linux and Windows. There might be a slight advantage in favor of Linux, but there are also many using Windows.

It's best to have a good setup of GNU tools on your system. Here is a list of the most valuable tools you'll need:

  • binutils (contains the assembler as, linker ld, disassembler objdump, and other useful tools)
  • GNU compiler collection (gcc and g++ compilers, plus more exotic ones e.g. for Fortran or ADA)
  • grep and sed (which allow for powerful and complex search/search & replace from the command line)
  • make (for automating the build process, which becomes really helpful once you have more than a handful of files)
  • diffutils (contains diff, cmp and diff3 to show where files differ)
  • perl (which can save you hours in miscellaneous text-manipulation tasks. You'll be using it sooner or later, so rather install it soon :)


Windows

In order to get the tools necessary you need to install either Cygwin, MinGW or DJGPP. Using Cygwin is recommended.

You will also need an editor. Using Notepad will work, but it's easier if you have an editor with syntax highlighting and ability to start compilation.

For instance Notepad++ or Notepad2 can be used.

Linux

When using Linux most of the GNU tools are probably already present. If not try using apt-get, rpm or download the source to install.

Common editors are vim, exim or kdevelop3.


Testing your operating system
Main article: Testing

All throughout development you will need to test new versions of your OS/Kernel.

Protecting your code

During your code building you will write hundreds, even thousands, of lines of code. You'll spend an unmentionable number of hours, and sit up late at night coding when you really should go to bed. The last thing you need is a disk crash or a poorly written 'rm' or 'format' command throwing all your work away.

What you need is a version control system. CVS has been used for a number of years, but have gotten a lot of competition from Subversion lately. If you can you should set up a remote computer/server as a version control server, but if you do not have such a machine available you can also host the version control system on your local development computer. Just remember to backup your code to CD or FTP once in a while.

A convenient way of getting access of a Subversion server is to create a project over at sourceforge. You can also set up your project at Google Project Hosting or at HIT Open Source Platform(chinese)

Attaining further knowledge

Be prepared to read, because there is a lot of information on the net. You've already taken the first step by reading this introduction. Next up is to browse through other parts of this Wiki, and creating a profile in the forum.

You should take a look at the following sites as well:

Check out the Resources page for further reading as well.

Also there are several books written about OS development. See the Books page and the book reviews over at Bona Fide.