What processor facilities does an Operating System's Kernel need in order to perform it's functions?

An Operating System is a series of layers.

This article is the property of http://www.binarysoldier.net

Each layer is a set of functions which depend upon the layer beneath it (it is often portrayed as an onion).

The very first innermost layer of an operating system is the System Nucleus (also known as the Operating System Kernel) and is only dependent upon the actual hardware of the computer. It is often the only part of an operating system that is coded in Assembly Language. For the kernel to operate, it is dependent on four processor facilities.

These are:

1) An Interrupt Mechanism

2) Memory Protection

3) A Privileged Instruction Set

4) A Real-Time Clock

I shall look at each facility in turn:

1) Interrupt Mechanism:

As the processor(s) operate much faster than the peripherals it controls, it is able to switch to other tasks while waiting for the peripherals to complete their tasks. Foe example, a user is able to use the mouse while the printer is printing a document. This is because once the processor has given the printer it's task it switches back to monitoring the mouse movements.

In order to allow these I/O devices to overlap, the I/O peripherals must be able to interrupt the processor when a device completes it's task. It is the Interrupt Mechanism that provides this functionality. When an interrupt occurs (ie: the device signals it has completed it's task), the Interrupt Mechanism will save the value of the current process being performed by the processor and give control to a fixed location in memory which holds the start of the interrupt service routine. The First Level Interrupt Handler (FLIH) will then find the source of the interrupt and respond to it in the required way. It will perform the task requested by the device issuing the interrupt.

Some systems however do not have an Interrupt Routine, they use peripheral processors instead.

2) Memory Protection:

Due to the fact that use of an Interrupt Mechanism allows several processes to run concurrently (ie: several processes run at the same time in multi processor systems, or appear to be running at the same time in a single processor system because of the high speed the processes are interwoven, causing the illusion of multi tasking), the memory the proceses are using needs to be protected from use by the other processes, unles authorised to do so.

3) Privileged Instruction Set:

Due to the use of concurrent processes, part of the instruction set is reserved for use exclusively by the operating system. This is called the Privileged Instruction Set.

Computers run in two modes. One is the User Mode and the second is the Supervisor Mode. The Privileged Instruction Set can only operate while the computer is in Supervisor Mode. Whilst in Supervisor Mode, the privileged instruction set can perform the following tasks:

1) Enable and disable interrupts

2) Perform input or output

3) Switch a processor between processes

4) Access the registers used by the memory protection hardware

5) Stop and/or control a processors operations

In order to switch from User Mode to Supervisor Mode one of the following circumstances must occur:

1) An interrupt must occur

2) A process must ask the operating system to perform a task which requires use of the privileged instruction set.

3) Whilst in User Mode there is an interrupt to perform a task requiring the privileged instruction set. This is classed as an error.

4) An error occurs in a process (such as in 3) and is treated as an internal interrupt and so is handled by an interrupt routine where possible.

In order to switch back from Supervisor Mode to User Mode, a privileged instruction is used.

4) Real time clock:

The final hardware item needed by the operating system's kernel is a real time clock and it's role is to provide the real time (ie: hours, minutes, seconds, not clock cycles).

It is used to schedule tasks such as checking resources used by users and the implementation of scheduling policies. In a multiprocessor computer, there is still only a single real time clock, used by all the processors.

This article is the property of http://www.binarysoldier.net

This is the book I would recommend for anyone wishing to gain an understanding of the basic fundamentals of operating systems.

The subjects contained within are explained much more clearly than the other books I have read on the same subject. Whilst it may not go into as much depth as other books, I found it was this book which provided me a good solid understanding in an easy to understand way.