Introduction

From OSDev Wiki
(Redirected from Shell)
Jump to: navigation, search

Contents

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 OS development, 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 OSDev'ing? You should read the Getting Started article. If you are going to use C/C++ as your language of choice, you are required to build a GCC Cross-Compiler first. And if you prefer to use other Languages then it is important to have some similar tools (e.g. compiler) or if there's no such tools it is often only your efforts that can help you. But going along with your preferred language can add some motivation and excitement during your work.

Good luck!

What is an Operating System?

An operating system is a software controlling the operation of a computer system and its resources. Among other things, there's one very important criteria common to all operating systems:

 Capable of loading and executing user programs providing standardized (hardware-independent) input / output interface for them.

Major functions of operating systems may include:

  • Managing memory and other system resources.
  • Imposing security and access policies.
  • Scheduling and multiplexing processes and threads.
  • Launching and closing user programs dynamically.
  • 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, or may work with a static set of user programs.

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.

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 exist; 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. However, there are alternatives to widget libraries, usually in the form of declarative languages (e.g., Mozilla's XUL, Qt's QML).

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.

See Also

Articles

Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox