Getting Started: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(→‎Required Knowledge: added programming experience as a prerequisite.)
(→‎Choosing your development environment: reformat to match rest of page, added lots of links.)
Line 26: Line 26:


==Choosing your development environment==
==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.
You need a platform to develop your new system on. Following the trends of general computing, the two most popular are Windows and GNU/Linux. Developers using a GNU/Linux system have a slight advantage in availability of tools, but this can be solved on Windows using a system such as [[Cygwin]]. The GNU toolset is generally recognised as the best for OSDev, and so it is useful to have a good selection of them:


* '''binutils''': Fundamental tools for manipulation of object files.
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:
* '''[[GCC]]''': The GNU Compiler Collection. GCC contains compilers for C, C++, Fortran and ADA, amongst others.
* binutils (contains the assembler as, linker ld, disassembler objdump, and other useful tools)
* '''[[Makefile|Make]]''': For automating the build process, which becomes really helpful once you have more than a handful of files.
* [[GCC|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)
* '''grep''' and '''sed''': For doing more powerful searches and search and replaces (helpful when filling out tables with data).
* '''diffutils''': Incredibly useful for showing the differences between two files.
* make (for automating the build process, which becomes really helpful once you have more than a handful of files)
* '''[[Wikipedia:Perl|Perl]]''' or '''[[Wikipedia:Python_(programming_language)|Python]]''': One of these two scripting languages should be installed. Useful for string manipulation, amongst other things. Perl used to be the recommendation, but Python is now quite mature, and is possibly easier to learn. Both have hundreds of packages/modules available for doing various tasks.
* 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 :)


You might not use all of these tools, but it is best to have them on hand 'just in case', and know how to use them, even at a basic level.
===Windows===
In order to get the tools necessary you need to install either [[Cygwin]], [[MinGW]] or [[DJGPP]]. Using Cygwin is recommended.


===Windows===
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.
In order to get the tools necessary you need to install either [[Cygwin]], [[MinGW]] or [[DJGPP]]. Using Cygwin is recommended. Note that it is almost necessary to create a [[GCC Cross-Compiler|cross-compiler]] when using Windows.


For instance [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://www.flos-freeware.ch/notepad2.html Notepad2] can be used.
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 [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://www.flos-freeware.ch/notepad2.html Notepad2] can be used.


===Linux===
===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.
When using Linux most of the GNU tools are probably already present. If not try using your distrobution's packages tools(apt-get, rpm,emerge) or download the source to install (which is only useful if you already have a compiler). Again, making a cross-compiler is reccomended.


Common editors are vim, exim or kdevelop3.
Common editors are [[Wikipedia:Vim|vim]], [[Wikipedia:Emacs|Emacs]] or [[Wikipedia:KDevelop|KDevelop]].


===Testing your operating system===
===Testing your operating system===

Revision as of 23:27, 16 September 2007

This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

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!

The Hard Truth

Hopefully the basic fact that operating system development is a complicated and on-going process does not discourage you. The truth is, operating system development is truly unparalleled since it requires the utmost amount of patience, careful code design and returns very little to no "instant gratification" you get from the development of things like games and web based scripting.

You have been fairly warned of the hard work ahead, but if you are still interested then proceed forward into the realm of the operating system programmer. Prepare yourself for ocassional bouts of confusion, discouragement, and for some of us... temporary insanity. In time, and with enough dedication, you will find yourself among the elite few who have contributed to a working operating system. If you do get discouraged along the way, refresh yourself with the contents of this book, hopefully it will remind you of why you started such an insane journey in the first place.

Responsibility

People tend to claim that it is OK to write inefficient software, stating that computer systems are so fast these days, that you won't see the impact. This type of mentality is dangerous in operating system design. It might be OK to write sloppy code when making a simple application, but when it comes to critical code that may get called thousands of times per second, you need to take out all the overhead you can. The operating system should supply the computer as a basic resource to the running application's', with as little complication, abstraction and overhead as possible.

People who design operating systems in this day and age tend to have the "everything but the kitchen sink" mentality. They take it upon themselves to account for everything, which of course is good, but it shouldn't be done in order to allow poorly written programs to flurish. There are many things that go on "under the hood" when program errors occur. Poorly written programs cost precious execution time, and involve task switches that are expensive in both memory and frequency. We encourage you to discourage poorly written software.

Required Knowledge

I'm not going to lie. Operating system development is difficult. But having the right knowledge can make it a lot easier. Handy skills to have are:

  • 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, even if you plan to write most of your operating system in another language.
  • C / C++: Most of the operating systems featured on this site are written in C (or C++), and a good understanding of this is required. Even if you choose to use another language like FreeBASIC or Pascal, code on the Internet is almost always in C (which can be considered the lingua franca of programming).
  • Programming experience: Learning a language with OS development is considered a bad idea. You should know the language in which you will be developing inside out, which means you should have written quite a few programs in that language successfully.
  • 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.

Choosing your development environment

You need a platform to develop your new system on. Following the trends of general computing, the two most popular are Windows and GNU/Linux. Developers using a GNU/Linux system have a slight advantage in availability of tools, but this can be solved on Windows using a system such as Cygwin. The GNU toolset is generally recognised as the best for OSDev, and so it is useful to have a good selection of them:

  • binutils: Fundamental tools for manipulation of object files.
  • GCC: The GNU Compiler Collection. GCC contains compilers for C, C++, Fortran and ADA, amongst others.
  • Make: For automating the build process, which becomes really helpful once you have more than a handful of files.
  • grep and sed: For doing more powerful searches and search and replaces (helpful when filling out tables with data).
  • diffutils: Incredibly useful for showing the differences between two files.
  • Perl or Python: One of these two scripting languages should be installed. Useful for string manipulation, amongst other things. Perl used to be the recommendation, but Python is now quite mature, and is possibly easier to learn. Both have hundreds of packages/modules available for doing various tasks.

You might not use all of these tools, but it is best to have them on hand 'just in case', and know how to use them, even at a basic level.

Windows

In order to get the tools necessary you need to install either Cygwin, MinGW or DJGPP. Using Cygwin is recommended. Note that it is almost necessary to create a cross-compiler when using Windows.

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 your distrobution's packages tools(apt-get, rpm,emerge) or download the source to install (which is only useful if you already have a compiler). Again, making a cross-compiler is reccomended.

Common editors are vim, Emacs or KDevelop.

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

There is an amazing amount of knowledge about operating system development available on the Internet today. It's just a matter of finding it. First of all, there is this wiki itself. Since you're here, you've probably already found it. Also on this site is the forum, where many developers hang out and can help you (but make sure you read How To Ask Questions first). Quite a few books on operating system development have been written. A number of these are featured on our Books page, and more over at osdever.net as well.

These sites also have good information on them:

Check out the Resources page for further reading as well.