Introduction: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Merging "Definitions", some rewriting.)
Line 6: Line 6:
Whatever your goals, OSDev'ing is the great pinnacle of programming. But, you're not alone. In fact, this entire website, including the [http://forum.osdev.org forums] and this Wiki, are dedicated to OSDev'ing. This is not only about great programming skills, but is about community and developing friendships. Be those friendships between fellow forum members or IRQs and processes.
Whatever your goals, OSDev'ing is the great pinnacle of programming. But, you're not alone. In fact, this entire website, including the [http://forum.osdev.org forums] and this Wiki, are dedicated to OSDev'ing. This is not only about great programming skills, but is about community and developing friendships. Be those friendships between fellow forum members or IRQs and processes.


What do you need to succeed in OSDeving? You should read the [[Getting Started]] article.
What do you need to succeed in OSDeving? You should read the [[Getting Started]] article. If you are going to use C/C++ as your language of choice, we generally recommend building a [[GCC Cross-Compiler]] first thing.


Do you want to read a step-by-step tutorial to writing a basic kernel you can build upon? You should read [http://osdever.net/bkerndev/Docs/intro.htm Bran's Kernel Development Tutorial], and the article about [[Bran's Known Bugs]]. Once you know the bare basics, you may find some more tutorials at the [[Tutorials]] page.
Do you want to read a step-by-step tutorial to writing a basic kernel you can build upon? You should read [http://osdever.net/bkerndev/Docs/intro.htm Bran's Kernel Development Tutorial], and the article about [[Bran's Known Bugs]]. There is also the Assembler-based [[:Category:Babystep | BabyStep Tutorial]] or, if you don't want that much hand-holding but still want a kickstart, [[:Category:Bare bones tutorials | Bare Bones tutorials]] for several languages. Once you know the basics, you will find even more [[Tutorials]] on various things.


Good luck! :)
Good luck! :)


== What is an Operating System? ==
== What is an Operating System? ==

Computer systems in general are a finite resource. Their entire purpose is to execute a set of instructions, something we commonly call a "program". This concept has not changed much over the years. Early main-frame system administrators had the job of taking program execution requests, assigning them a priority, and giving them a time frame to run. These concepts are the basis of any operating system, they just tend to occur thousands of times per second. The operating system can allow execution of multiple programs so quickly that it is virtually unnoticeable to a human user, making it seem as all the programs are running at the same time. Many things have to occur in order to allow multiple programs to execute in such a manner. The priority is safety, because if the system crashes and becomes unusable, not much else matters. Second is security, denying the capability of malicious programs, such as viruses and worms, to wreak havoc on the system is a must. Even more so is security-related software, denying access to such software's memory space is imperative. The last major issue is speed; If software runs slow or takes up valuable system resources, it makes a run-away impact on the rest of the system.
An operating system is a software controlling the operation of a computer system and its resources. Major functions of operating systems may include:

* Managing memory and other system resources.
* Managing and directing device drivers.
* Imposing security and access policies.
* Scheduling and multiplexing processes and threads.
* Launching and closing user programs, and providing basic system services for them.
* Providing a basic user interface and application programmer interface.

Not all operating systems provide all of these functions. Single-tasking systems like MS-DOS would not schedule processes, while embedded systems like eCOS may not have a user interface.

An operating system is *not*:

* The computer hardware.
* A specific application such as a word processor, web browser or game.
* A suite of utilities (like the GNU tools, which are used in many Unix-derived systems).
* A development environment (though some OSes, such as UCSD Pascal or Smalltalk-80, incorporate an interpreter and IDE).
* A Graphical User interface (though many modern operating systems incorporate a GUI as part of the OS).

While most operating systems are distributed with such tools, they are not themselves a necessary part of the OS. Some operating systems, such as Linux, may come in several different packaged forms, called _distributions_, which may have different suites of applications and utilities, and may organize some aspects of the system differently. Nonetheless, they are all versions of the same basic OS, and should not be considered to be separate types of operating systems.

Current (2011) operating systems include:

* Windows
* MacOS X
* Linux
* FreeBSD
* SkyOS
* Plan 9

There have been many other operating systems in the past, and many others currently which are not listed here. At any given time there are several projects to develop new operating systems in the works.

== What is a kernel ? ==

The kernel of an operating system is something you will never see. It basically enables any other programs to execute. It handles events generated by hardware (called ''interrupts'') and software (called ''system calls''), and manages access to resources.

The hardware event handlers (''interrupt handlers'') will for instance get the number of the key you just pressed, and convert it to the corresponding character stored in a buffer so some program can retrieve it.

The ''system calls'' are initiated by user-level programs, for opening files, starting other programs, etc. Each system call handler will have to check whether the arguments passed are valid, then perform the internal operation to complete the request.

Most user programs do not directly issue system calls (except for ASM programs, for instance), but instead use a ''standard library'' which does the ugly job of formatting arguments as required by the kernel and generating the system call. (For example, the C function ''fopen()'' eventually calls a kernel function that actually opens the file.)

The kernel usually defines a few ''abstractions'' like files, processes, sockets, directories, etc. which correspond to an internal state it remembers about last operations, so that a program may issue a session of operation more efficiently.

== What is a shell ? ==

A shell is a special program that is usually integrated in an OS distribution, and which offers humans an interface with the computer. The way it appears to users may vary from system to system (command line, file explorer, etc), but the concept is always the same:

* Allow the user to select a program to be started, and optionally give it session-specific arguments.
* Allow trivial operation on the local storage like listing the content of directories, moving and copying files across the system.

In order to complete those actions, the shell may have to issue numerous system calls, like "open file 'x'; open file 'y' and create it if it doesn't exists; read content from X, write into Y, close both files, write 'done' to standard output".

The shell may also be used by programs that want to start other programs but do not want to do this themselves (e.g. completing file patterns like '*.mp3', retrieving the exact path of the program, etc.).

Modern shells can also have various extra features, such as the following:

* Auto-Completion: By pressing the TAB (or any preferred) key, the word the user is typing will be completed to a valid shell command, a file, directory, or something else. Pressing the auto-complete key multiple times cycles through other completion possibilities.
* Character Insertion: The user can move around in what he or she entered by using the arrow keys. When typing new characters in the middle of a sentence, characters will get 'inserted'.
* Shell History: By using the up and down arrow keys, the user can scroll through previous input.
* Scrolling: When there are more lines than the console is high, save the output in a buffer and allow the user to scroll up and down in the console.
* Scripting: Some shells have custom scripting languages. Examples of scripting languages are bash or DOS batch.
* ...

== What is a GUI about ? ==

The Graphical User Interface is the most visible part of any operating system that has one. Its role goes beyond a simple drawing library; it must also be able to:

* Catch user input events (keyboard, mouse, etc.) and dispatch them to the proper object.
* Update the internal information of what is to be displayed where on the screen, determining which parts of the screen need to be redrawn.
* Update the ''visible'' screen contents, redrawing the necessary parts.
* Do so in a way that feels natural, intuitive, and responsive to the user.

=== Desktop Environment, Window Manager, Widget Library ===

When you are launching into a KDE or Windows session, that is a ''desktop environment'', i.e. a graphical shell providing the functional environment for all lower-level functions.

The part of the system responsible for organizing the windows of the various running programs, their resizing / closing gadgets, window borders, scrollbars etc. is the ''Window Manager''.

Finally you have the subsystem that does the drawing of control elements, rendering documents on screen etc.; this is commonly called the ''widget library''.

=== GUI-related forum threads ===

* [[Topic:8783|Will you implement a GUI?]]
* [[Topic:9432|GUI design]]
* [[Topic:9448|Handling input events in GUI]]


== Why develop an OS? ==
== Why develop an OS? ==

There are a number of reasons why people choose to develop an operating system. Although each individual developer may have their own, there are a number of reasons that are common between some (if not most) developers:
There are various reasons why people choose to develop an operating system. Each individual developer may have their own, but some reasons are common among some (if not most) developers:
* Having complete control over the machine. When developing an application or other userspace program, the developer has to take into consideration the code written by others: the operating system, the libraries, other programs, etc. It is a powerful feeling for the only code to be running on a machine to be your own.

* Research. Quite a few operating system projects are started as homework or research projects. While starting an operating system as a homework assignment in a pre-tertiary or first-year environment is generally considered a bad idea (due to short deadlines), a longer term project is quite fine. Research projects are usually undertaken to improve on the existing operating systems. A common beginner mistake, however, is to underestimate the time needed to write an operating system from scratch.
* Having complete control over the machine. When developing an application or other userspace program, the developer has to take the code written by others into consideration: the operating system, the libraries, other programs, etc. It is a powerful feeling for the only code to be running on a machine to be your own.

* Research. Quite a few operating system projects are started as homework or research projects. While starting an operating system as a homework assignment in a pre-tertiary or first-year environment is generally considered a bad idea (due to short deadlines), a long-term project is quite fine. Research projects are usually undertaken to improve on existing operating systems. A common beginner mistake, however, is to underestimate the time needed to write an operating system from scratch.

* To replace the currently available operating systems. Maybe they don't have a particular feature that the developer wants. Maybe they just generally suck (Linux is bloated, Windows is unstable, etc). This may be for profit; although any returns are likely to be a long time away.
* To replace the currently available operating systems. Maybe they don't have a particular feature that the developer wants. Maybe they just generally suck (Linux is bloated, Windows is unstable, etc). This may be for profit; although any returns are likely to be a long time away.

* Because it's fun. Low level programming is a fun and exciting task, because you have to do everything. This may seem more difficult (it is, don't worry) but by the same reasons more fun. You know how everything works, how it all fits, and the inner-most workings of your program.
* Because it's fun. Low level programming is a fun and exciting task, because you have to do everything. This may seem more difficult (it is, don't worry) but by the same reasons more fun. You know how everything works, how it all fits, and the inner-most workings of your program.

Unfortunately, many operating system projects are undertaken for the wrong reasons. See [[Beginner Mistakes]] for a list.
Unfortunately, many operating system projects are undertaken for the wrong reasons. See [[Beginner Mistakes]] for a list.



Revision as of 07:11, 16 December 2011

Welcome

Welcome to Operating System development; the great frontier.

Not all "make it" in this field, many don't even pass the "Hello World" of OSDev, but perhaps you will go further and create the next Linux? Or Windows? Or are your goals lower - MenuetOS? Or even CP/M?

Whatever your goals, OSDev'ing is the great pinnacle of programming. But, you're not alone. In fact, this entire website, including the forums and this Wiki, are dedicated to OSDev'ing. This is not only about great programming skills, but is about community and developing friendships. Be those friendships between fellow forum members or IRQs and processes.

What do you need to succeed in OSDeving? You should read the Getting Started article. If you are going to use C/C++ as your language of choice, we generally recommend building a GCC Cross-Compiler first thing.

Do you want to read a step-by-step tutorial to writing a basic kernel you can build upon? You should read Bran's Kernel Development Tutorial, and the article about Bran's Known Bugs. There is also the Assembler-based BabyStep Tutorial or, if you don't want that much hand-holding but still want a kickstart, Bare Bones tutorials for several languages. Once you know the basics, you will find even more Tutorials on various things.

Good luck! :)

What is an Operating System?

An operating system is a software controlling the operation of a computer system and its resources. Major functions of operating systems may include:

  • Managing memory and other system resources.
  • Managing and directing device drivers.
  • Imposing security and access policies.
  • Scheduling and multiplexing processes and threads.
  • Launching and closing user programs, and providing basic system services for them.
  • Providing a basic user interface and application programmer interface.

Not all operating systems provide all of these functions. Single-tasking systems like MS-DOS would not schedule processes, while embedded systems like eCOS may not have a user interface.

An operating system is *not*:

  • The computer hardware.
  • A specific application such as a word processor, web browser or game.
  • A suite of utilities (like the GNU tools, which are used in many Unix-derived systems).
  • A development environment (though some OSes, such as UCSD Pascal or Smalltalk-80, incorporate an interpreter and IDE).
  • A Graphical User interface (though many modern operating systems incorporate a GUI as part of the OS).

While most operating systems are distributed with such tools, they are not themselves a necessary part of the OS. Some operating systems, such as Linux, may come in several different packaged forms, called _distributions_, which may have different suites of applications and utilities, and may organize some aspects of the system differently. Nonetheless, they are all versions of the same basic OS, and should not be considered to be separate types of operating systems.

Current (2011) operating systems include:

  • Windows
  • MacOS X
  • Linux
  • FreeBSD
  • SkyOS
  • Plan 9

There have been many other operating systems in the past, and many others currently which are not listed here. At any given time there are several projects to develop new operating systems in the works.

What is a kernel ?

The kernel of an operating system is something you will never see. It basically enables any other programs to execute. It handles events generated by hardware (called interrupts) and software (called system calls), and manages access to resources.

The hardware event handlers (interrupt handlers) will for instance get the number of the key you just pressed, and convert it to the corresponding character stored in a buffer so some program can retrieve it.

The system calls are initiated by user-level programs, for opening files, starting other programs, etc. Each system call handler will have to check whether the arguments passed are valid, then perform the internal operation to complete the request.

Most user programs do not directly issue system calls (except for ASM programs, for instance), but instead use a standard library which does the ugly job of formatting arguments as required by the kernel and generating the system call. (For example, the C function fopen() eventually calls a kernel function that actually opens the file.)

The kernel usually defines a few abstractions like files, processes, sockets, directories, etc. which correspond to an internal state it remembers about last operations, so that a program may issue a session of operation more efficiently.

What is a shell ?

A shell is a special program that is usually integrated in an OS distribution, and which offers humans an interface with the computer. The way it appears to users may vary from system to system (command line, file explorer, etc), but the concept is always the same:

  • Allow the user to select a program to be started, and optionally give it session-specific arguments.
  • Allow trivial operation on the local storage like listing the content of directories, moving and copying files across the system.

In order to complete those actions, the shell may have to issue numerous system calls, like "open file 'x'; open file 'y' and create it if it doesn't exists; read content from X, write into Y, close both files, write 'done' to standard output".

The shell may also be used by programs that want to start other programs but do not want to do this themselves (e.g. completing file patterns like '*.mp3', retrieving the exact path of the program, etc.).

Modern shells can also have various extra features, such as the following:

  • Auto-Completion: By pressing the TAB (or any preferred) key, the word the user is typing will be completed to a valid shell command, a file, directory, or something else. Pressing the auto-complete key multiple times cycles through other completion possibilities.
  • Character Insertion: The user can move around in what he or she entered by using the arrow keys. When typing new characters in the middle of a sentence, characters will get 'inserted'.
  • Shell History: By using the up and down arrow keys, the user can scroll through previous input.
  • Scrolling: When there are more lines than the console is high, save the output in a buffer and allow the user to scroll up and down in the console.
  • Scripting: Some shells have custom scripting languages. Examples of scripting languages are bash or DOS batch.
  • ...

What is a GUI about ?

The Graphical User Interface is the most visible part of any operating system that has one. Its role goes beyond a simple drawing library; it must also be able to:

  • Catch user input events (keyboard, mouse, etc.) and dispatch them to the proper object.
  • Update the internal information of what is to be displayed where on the screen, determining which parts of the screen need to be redrawn.
  • Update the visible screen contents, redrawing the necessary parts.
  • Do so in a way that feels natural, intuitive, and responsive to the user.

Desktop Environment, Window Manager, Widget Library

When you are launching into a KDE or Windows session, that is a desktop environment, i.e. a graphical shell providing the functional environment for all lower-level functions.

The part of the system responsible for organizing the windows of the various running programs, their resizing / closing gadgets, window borders, scrollbars etc. is the Window Manager.

Finally you have the subsystem that does the drawing of control elements, rendering documents on screen etc.; this is commonly called the widget library.

GUI-related forum threads

Why develop an OS?

There are various reasons why people choose to develop an operating system. Each individual developer may have their own, but some reasons are common among some (if not most) developers:

  • Having complete control over the machine. When developing an application or other userspace program, the developer has to take the code written by others into consideration: the operating system, the libraries, other programs, etc. It is a powerful feeling for the only code to be running on a machine to be your own.
  • Research. Quite a few operating system projects are started as homework or research projects. While starting an operating system as a homework assignment in a pre-tertiary or first-year environment is generally considered a bad idea (due to short deadlines), a long-term project is quite fine. Research projects are usually undertaken to improve on existing operating systems. A common beginner mistake, however, is to underestimate the time needed to write an operating system from scratch.
  • To replace the currently available operating systems. Maybe they don't have a particular feature that the developer wants. Maybe they just generally suck (Linux is bloated, Windows is unstable, etc). This may be for profit; although any returns are likely to be a long time away.
  • Because it's fun. Low level programming is a fun and exciting task, because you have to do everything. This may seem more difficult (it is, don't worry) but by the same reasons more fun. You know how everything works, how it all fits, and the inner-most workings of your program.

Unfortunately, many operating system projects are undertaken for the wrong reasons. See Beginner Mistakes for a list.