by May 1, 1999 0 comments

Have you ever wondered what really goes on behind all the
windows on your desktop? Whether you’re using Win 98 or NT, Linux or just plain old
DOS, the operating system forms the crucial link between you and your computer. In this
article, we’ll explore how this complex piece of software works.

The operating system (OS) sits between your hardware and
the apps on your machine. Whenever you open a file in Word, for instance, the operating
system is responsible for locating the file on your hard disk and supplying it to Word. If
you’re playing a music file, the OS sends it to the sound card, which in turn plays
the music on your speakers. Whenever you’re playing a game, it’s the OS that is
pushing the graphics on to the display card. In short, almost everything you do on your
system is controlled by the operating system.

The kernel

kernel.JPG (13602 bytes)At the heart of an
operating system lies the kernel. This part of the OS works like a manager of your system
resources. It controls the various devices attached to your computer, supervises the
programs running on your system, and allocates system memory among these programs.
It’s also responsible for managing the files stored on your disk drives.

The kernel is segregated into several subsystems including
input/output, process management, and the file subsystem. The input/output subsystem is
responsible for communicating with the devices attached to your computer. The process
management subsystem handles the apps running on your computer. It allocates memory to
your programs, sees to their communication requirements, and handles multi-tasking and
multi-threading between the programs. The file subsystem manages the files stored on your
system. It’s responsible for all permanent storage including your hard disk, floppy
disks, CD-ROM drives, and so on.

Another major component of an operating system is its user
interface, which may be graphical or text based. GUIs first originated at the Xerox PARC
Labs and since then have been adopted by almost all operating systems. The Windows OSs are
well-known for their GUIs; Linux and other Unixes usually come with the X Window System,
and even real-time operating systems like QNX come with some really neat GUIs. Since the
GUI is a highly complex piece of code and covering it is a task unto itself, we’ll
not undertake that here.

Booting up

Before we take a closer look at each of these components,
let’s see how an operating system starts itself. This is a systematic procedure,
which is best explained in a step-by-step manner.

  • When the system is switched on, a program called the BIOS
    (Basic Input/Output System) activates itself. This program is permanently stored on a ROM
    chip in your computer and is responsible for coordinating all the hardware components on
    your computer.
  • The BIOS looks for a program, a bootstrap loader, loads it
    into memory and executes it. This program usually sits on the hard disk that contains the
    operating system. The bootstrap loader locates the operating system’s kernel and
    executes it.
  • Upon starting, the kernel initializes the operating system
    services, and finally proceeds to activate the graphical user interface.

Now that our operating system has booted, let’s see
how each of its more important subsystems do their work.

The input/output subsystem

All peripheral devices attached to your system communicate
with running applications through the I/O subsystem of your OS. When you’re typing a
letter in a word processor, the keystrokes travel from your keyboard to the I/O subsystem
and then to your word processor. While downloading a file from the Net, the modem is
actually sending all its data to this I/O subsystem.

A device driver is a part of the I/O subsystem which
actually communicates with a device. Each device has its own device driver. For example,
your video card has its own device driver, so does your sound card and your modem. Right
down from your floppy drive all the way up to your faster-than-lightning 3D accelerator
card, all devices on your system need their respective device drivers to be able to do
their work.

Whenever an app needs to communicate with a device, it
sends a request to the operating system. The operating system in turn passes this request
to the appropriate device driver. The device driver converts the request into machine
language instructions directly understandable by the device. It then sends these
instructions to the device. If the device returns some data, it passes it back to the OS.
The OS then returns this data back to the app.

Let’s take a simple example to illustrate this. Say,
you want to play an MP3 file on your brand-new sound card. The MP3 player decodes this
file converting it into a sound signal, which it sends to the operating system. The OS in
turn sends this signal down to the sound card’s device driver. This device driver
knows how to handle the signal and tells the sound card to play it on your speakers.
It’s that simple!

Some operating systems like Unix use special device drivers
for accessing system memory. Yes, that’s right, these operating systems don’t
access your oodles of RAM directly, opting instead to let device drivers do all the work.

The process subsystem

Arguably, the most important component of an operating
system, the process subsystem manages all the apps that you run on your computer. In
operating system parlance, a program that is running on your system is known as a process.
When you double-click the Quake II icon on your Windows desktop, the OS first locates the
program file quake2.exe on your hard disk. It then proceeds to load the file into memory
and pass control of it to the process subsystem.

The process subsystem is responsible for running this
process along with all the other processes that are already executing. In other words, it
has to multi-task all these processes. To do this, the process subsystem first creates a
context of the process, which stores the address of the process the status of all its
variables and lots of other related data.

That done, another part of the process subsystem, the
process scheduler, kicks in. The scheduler goes through all the processes on the system,
running each one for a small amount of time, known as a time slice. Upon expiry of this
time slice, the scheduler saves the current state of the running process into its context
and switches to the next process on its list. This is how an operating system generally
does its multi-tasking.

The process subsystem is also responsible for protecting
the running processes from each other. No, they don’t generally go attacking each
other, but sometimes a process may accidentally try to write into memory belonging to
another process. If such a thing is allowed to happen the system would stop working.
Incidentally, this is what happens with many buggy applications.

When you drag and drop a file from your desktop onto the
printer icon, you are engaging in a very high level of inter-process communication.
Whenever two processes need to talk to each other, the process subsystem manages the
conversation. Many different methods of such communication are available, including
signals, semaphores and sockets. The Windows operating system use the rather popular
object linking and embedding (OLE) protocol, which allows you to drag and drop objects
between running apps.

Last, the process subsystem controls your system’s
memory, allocating it to processes, freeing up unused memory, and managing virtual memory.
Virtual memory is a technique of tricking processes into thinking that they have more
memory than actually exists on the system. Imagine for a moment that you’re playing
Unreal and you land up in a very complex level. Unreal requests the operating system for
more memory to process the associated information, which is not available. Instead of
returning an error, the process subsystem moves another app out of memory and gives Unreal
its memory.

The file subsystem

Every time you open a file in Word, the file subsystem
looks through your hard disk, locates your document and sends it to Word. Thus the file
subsystem is responsible for organizing files kept on your hard disk, on your CDs, and all
the other permanent storage devices that you use.

A file system is a particular way of organizing files on a
storage device. Compact disks use the ISO 9660 file system; Windows series of operating
systems use the FAT16, FAT32 and the NTFS file systems; Linux uses the Ext2 file system.
Any modern operating system usually implements support for all these file systems, along
with supporting its own file systems.

The file subsystem coordinates with the I/O subsystem to do
its job. That is, it cannot work with the various storage devices on its own. As
you’ve already seen, the I/O subsystem is responsible for talking to these devices.
Therefore, the file system sends its requests to the I/O subsystem, which does the actual
communication with the various storage devices.

By now, you should be generally familiar with the essential
parts of an operating system and how they work. Do remember that operating system design
is an area of specialization in computer science, and makes for fascinating study. There
are several good books available that discuss operating systems in detail. If you want to
learn more about this topic, I’d suggest you head for your local computer bookstore.

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.