Definitions
From OSDev Wiki
Contents |
What is an Operating System ?
An operating system is a program or suite of programs which controls the operation of a computer system. Major functions of an operating system may include:
- Managing memory and other system resources
- Managing and directing the device drivers
- Providing basic system services to the user programs
- Imposing security and access policies
- Scheduling and multiplexing processes and threads
- Launching and closing user programs
- Providing a basic user interface and application programmer interface
However, not all operating systems provide all of these functions; for example, single-tasking system such as MS-DOS would not schedule processes, while an embedded system such as eCOS may not have a user interface.
An operating system is *not*
- The computer hardware
- An application such as a word processor, web browser or game
- A suite of utilities (e.g., the GNU tools which are used in many Unix derived systems)
- A compiler, interpreter or 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, the tools 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 seperate types of operating systems.
Current (2008) operating systems include
- Windows XP
- 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 your programs to execute. It handles events generated by hardware (called interrupts) and software (called system calls), and manages access to ressources.
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 any OS distribution and which offers humans an interface with the kernel. 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 optionnally 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 'all the ugly job' by themselves (e.g. completing file patterns like *.mp3, retrieving the exact path of the program, etc)
What is a GUI about ?
The Graphical User Interface is the most visible part of a modern Operating System. Its role goes beyond a simple drawing library: it must also be able to ...
- store informations about what is to be redrawn (not only which window, but also often which widget in each window)
- browse those infos and call the redrawing functions of each component. A smart way to do this is to define a virtual class (widget?) that will have a virtual draw(context) method that will draw the object in the current context. GUIs are often recursive, i.e. a menubar.draw() function will call each menubutton.draw() in order, with a context that is changed (i.e. each button reduces the remaining width) along the list...
- catch user inputs (keyb, mouse, etc.) and dispatch them to the proper object (i.e. the one that has the focus: when a mouse click occurs, follow your GUI infos to find out the object that is under the mouse pointer and then call its virtual function receive_event()
- sometimes, mask some events (i.e. some objects might not like to receive GUI_DRAGNDROP_EVENT, in this case, try to emit the event to the parent object. If no object can handle the event, just complain (beep, or whatever you like)
Note that I've been talking with classes and virtual functions ... encapsulated structures and function pointers basically do the very same job in non-OO languages ... and even in ASM ;-)
Widget Library, Window Manager and Desktop Environment
Let's call what you see when launching KDE or WinXP a "desktop environment", that is, a graphical shell with embedded widgets like toolbars, icons, etc. This has the same role as a startup menu and thus could be interresting even for Monotasking Systems (if you want to start DeluxePaint by clicking on a pencil rather than Typing DP2.BAT, why not after all)...
Let's call that boxes messes made of rectangles abstracting a screen for each running application in X or MS Windows the 'Window Manager'. There are two uses for such a manager:
- you have a system in which several programs run at the same time and often switch from one to another because you're actually doing a task that involves several programs.
- you have a single program that should display many things (documents ?) at the same time.
Finally you have the subsystem that helps drawing controls and rendering documents on screen. Let's call this the 'widget library'. The widget library is almost always interresting, though programs need to be written especially for it (thus a new widget library will not easily cope with legacy programs)
