Definition of an OS
Writer: Chiku
Date: November 19th, 1998
Os Development Requirements:
What is an Operating System ?
In crudest terminology it's the software that serves the following
purposes.
* Hardware Control
* Interaction with the user(s).
To achieve these objectives an OS is divided into following Parts.
* Loader
* Kernel
* Utilities
The Loader
In almost all the cases OS is the first piece of software that starts
to execute after the hardware has finished POST (Power On Self Test) or
BIST (Built In Self Test). This software is usually placed at a predetermined
memory location (by memory I don't necessarily mean RAM) to which the control
is transferred automatically. This procedure is called BootStrapping (booting
in more generic way). (BTW bootstrapping literally means lifting oneself
up using own bootstraps). The area that is usually given to this kind of
booting code is very small, typically a sector (usually 0th) of disk. The
primary responsibility
of the code in this area is to trigger off the Essential services of
the OS. This code is called Loader. The loader's primary responsibility
is to load the Kernel of the OS into memory (that also means transferring
the control to it).
The Kernel
The Kernel of an OS holds the 'highest' responsibility of smooth running
of the system. It is (usually) the kernel of an OS which performs
the task of controlling the hardware. In a typical scenario the Kernel
performs hardware initializations (also some s/w initialization like internal
data structures etc. which we can see during the course..) typically setting/resetting
the processor state, internal clock adjustments, Network Device initialization
etc. etc. All these jobs are very sensitive and should be done only by
trusted code. The protection (verification of trust level of code) usually
comes from the hardware. The hardware recognizes the code by a Privilege
Level (highest for the Kernel). And the thumb rule followed by
processor is that a code can always lower its privilege level but can
not elevate it, except in some special conditions which are predetermined
by the highest privilege level code (These are called traps or system calls).
Thus a Kernel on startup Initializes the hardware, does some very important
housekeeping functions and sets predetermined entry points to the trusted
code. It is not necessary that all of this trusted code (kernel) should
come from a single disk location. (A single file if filesystem is implemented).
The Kernel can provide certain entry points which can enable execution
of certain code at the highest privilege level at a later point in time,
and this facility is extensively used by moduled device driver approach.
The course of action followed is that, depending on the (hardware)
configuration the Kernel decides which code should be executed. This code
is loaded from the secondary memory into primary memory and assigned the
privilege level equivalent to that of the Kernel. (This code can again
follow the same suit :) ). At the end of such utter necessary initializations.
The Kernel changes its privilege level to a lower value and picks up the
code which Performs the job of User interaction.
The Utilities
This code is the outer layer (shell !!) of the OS which we can
term as the utilities. These are typically command interpreters, editors
etc. All these utilities have to depend on kernel entry points to do all
the h/w accesses. The shell's job is to invoke other programs and transfer
control to them.
Additional Complexity
In a multitasking environment the Kernel has an added responsibility.
It is to run multiple such utilities and switch between these utilities
such that the hardware utilization is optimum and there is no perceptible
delay in the execution. The Kernel usually achieves this by making use
of certain hardware features like the system clock, processor's context
mgmt facilities etc. The usual practice followed is that a clock keeps
interrupting the processor at a predefined interval which makes the processor
to abandon current execution and transfer the control to a portion of the
code which takes stock of current tasks and determines which is the task
that is to be given the next time slice. This task can be any of the tasks
in the system including the current task which has been recently abandoned.
The fineness of this switching depends on the task model employed by the
kernel which can be any of the Process, Thread or Fibre in the order.
The Ladder Model
An OS project needs These three (Loader, Kernel, bare minimum utils)
components to be decided upon first. The decision requires a lot of consideration
such as what entry point the kernel is going to provide, What kind of devices/hardware
it's going to deal with etc. These decisions are 'highly' influenced
by the nature of utilities which we want to provide. But one can clearly
see an interdependency. One should not decide upon a very complex outer
design which demands a high level of complexity in the kernel. The basic
idea is to start with a modest utility frame work and actually build
a prototype/working kernel required for this. Then slowly increase the
complexity of the utilities while enhancing the kernel. This can
be termed as the 'Ladder' model of development where two interdependent
goals proceed parallely supplementing each other's requirements. This Ladder
requires several crossbars to be a fully functional Ladder. In an Os project
these cross bars are typically the debugging tools such as the kernel debuggers
and the verification tools such as the test programs.
To Sum Up
An OS development initiative requires a set of goals for Overall primary
functionality of the Kernel and the Services. To proceed in the development
cycle (the ladder model way) actual prototype build is required along
with supplementary code such as debuggers and tests. The refinement should
be done as the time progresses.. |