Discussion:
Kernel and the layered software architecture
(too old to reply)
k***@kaxy.com
2007-07-16 19:43:43 UTC
Permalink
We have been having discussions lately regarding software architecture
layering for our embedded system. My architect has come up with a
layering diagram that starts from the hardware layer (i.e. layer 1).
Immediately above the hardware layer (i.e. at layer 2 level) he shows
2 layers ---- the kernel and the device driver layer. Additionally, a
sliver of the device driver layer is shown below the kernel layer,
implying the dependence of the kernel on the device drivers.

Now all this is hunky dory except that I disagree with showing the
kernel immediately above the hardware layer. How can the kernel
reside immediately above the hardware? I think that the kernel will
never be immediately above the hardware layer. It will always be
above the device driver layer. Without device drivers, the kernel
software cannot execute on the hardware platform. I would like to
redraw the layering diagram showing the kernel sitting totally on top
of the device driver layer. What do you say?

I am showing the two layering diagrams below. Kindly copy them into
notepad and view them there. Alternatively change the font to a fixed
width font. Any insight will be appreciated.

Thanks,
Bhat

_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| ______| |
| Kernel | Device |
| | Drivers |
|____________|____________|
| |
| Hardware |
|_________________________|

Architect's view





_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| | |
| Kernel | |
|__________________| |
| |
| Device Drivers |
|_________________________|
| |
| Hardware |
|_________________________|
My view
s***@gmail.com
2007-07-16 23:56:39 UTC
Permalink
Post by k***@kaxy.com
We have been having discussions lately regarding software architecture
layering for our embedded system. My architect has come up with a
layering diagram that starts from the hardware layer (i.e. layer 1).
Immediately above the hardware layer (i.e. at layer 2 level) he shows
2 layers ---- the kernel and the device driver layer. Additionally, a
sliver of the device driver layer is shown below the kernel layer,
implying the dependence of the kernel on the device drivers.
Now all this is hunky dory except that I disagree with showing the
kernel immediately above the hardware layer. How can the kernel
reside immediately above the hardware? I think that the kernel will
never be immediately above the hardware layer. It will always be
above the device driver layer. Without device drivers, the kernel
software cannot execute on the hardware platform. I would like to
redraw the layering diagram showing the kernel sitting totally on top
of the device driver layer. What do you say?
I am showing the two layering diagrams below. Kindly copy them into
notepad and view them there. Alternatively change the font to a fixed
width font. Any insight will be appreciated.
Thanks,
Bhat
I would tend to agree with the architect. Presumably interupts will
vector directly into the kernel. Also the kernel will directly access
the register set for tasks such as context switching and the like. You
are not suggesting you would write a driver for this are you?
slebetman@yahoo.com
2007-07-17 01:50:13 UTC
Permalink
Post by k***@kaxy.com
We have been having discussions lately regarding software architecture
layering for our embedded system. My architect has come up with a
layering diagram that starts from the hardware layer (i.e. layer 1).
Immediately above the hardware layer (i.e. at layer 2 level) he shows
2 layers ---- the kernel and the device driver layer. Additionally, a
sliver of the device driver layer is shown below the kernel layer,
implying the dependence of the kernel on the device drivers.
Now all this is hunky dory except that I disagree with showing the
kernel immediately above the hardware layer. How can the kernel
reside immediately above the hardware? I think that the kernel will
never be immediately above the hardware layer. It will always be
above the device driver layer. Without device drivers, the kernel
software cannot execute on the hardware platform. I would like to
redraw the layering diagram showing the kernel sitting totally on top
of the device driver layer. What do you say?
I am showing the two layering diagrams below. Kindly copy them into
notepad and view them there. Alternatively change the font to a fixed
width font. Any insight will be appreciated.
Thanks,
Bhat
_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| ______| |
| Kernel | Device |
| | Drivers |
|____________|____________|
| |
| Hardware |
|_________________________|
Architect's view
_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| | |
| Kernel | |
|__________________| |
| |
| Device Drivers |
|_________________________|
| |
| Hardware |
|_________________________|
My view
The kernel (or microkernel or hypervisor), in and of itself must run
directly on top of the CPU in order to manage the CPU. In the case of
a microkerneled or hypervisored system then yes, the kernel runs on a
virtual machine. But still the microkernel or hypervisor must in and
of itself run directly on the CPU in order to manage the CPU. So yes,
the kernel runs directly on top of the hardware.

Think of it this way:

_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| ______| |
| Kernel | Device |
| | Drivers |
|____________|____________|
| Hardware |
| | |
| CPU | Peripherals |
|________|________________|


The 'kernel' has full access of the CPU. It also has direct access to
some peripherals, the real-time clock for example which is usually a
separate chip on the motherboard. But it often requires device drivers
for other peripherals like the serial port.

Also in a lot of modern OSes, the device driver itself requires the
kernel and cannot access hardware directly. Take for example PCI
hardware where the device driver needs the kernel's services to map
PCI addresses to memory and the kernel's permission to access the PCI
bus.

To muddy up the distinction further. In some OSes like linux, a device
driver is part of the kernel. Linux device drivers (a.k.a kernel
modules) are to linux what plugins are to Adobe Photoshop. Some OSes
I've seen are so paranoid about hardware access that no userland
accessible device driver can access hardware directly leading to the
somewhat convoluted:

_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | Device |
| | Drivers |
| |____________|
| Kernel |
| ____________|
| | Kernel |
| | Device |
| | Drivers |
|____________|____________|
| |
| Hardware |
|_________________________|


In any case, as stated earlier, there should at least be one point
where the kernel touches the hardware directly: the CPU.
u***@gmail.com
2007-07-17 07:23:09 UTC
Permalink
Instead looking for plce of kernel into Any O.S. It is better to
think. Why do we need kernel.....
Kernel is used for the interface between utility programs and device
drivers...Kernel consists of software programs used to inteconnect
higher and lower layers.

1. Kernel manage system resources between hardware and software.
2. It provides lowest level of abstraction with system calls,
commands..

-----------------------------------------------------------
| Application |
--------------------------------------------------------------
| Kernel |
----------------------------------------------------------------
| CPU | Memory | Devices |
---------------------------------------------------------------
slebetman@yahoo.com
2007-07-18 03:32:07 UTC
Permalink
Post by u***@gmail.com
Instead looking for plce of kernel into Any O.S. It is better to
think. Why do we need kernel.....
Kernel is used for the interface between utility programs and device
drivers...Kernel consists of software programs used to inteconnect
higher and lower layers.
1. Kernel manage system resources between hardware and software.
2. It provides lowest level of abstraction with system calls,
commands..
-----------------------------------------------------------
| Application |
--------------------------------------------------------------
| Kernel |
----------------------------------------------------------------
| CPU | Memory | Devices |
---------------------------------------------------------------
Ahh but not all OSes partition things this way. In fact, only a
minority of OSes I've seen are so strict that device drivers cannot
directly communicate with hardware without going through the kernel.
Most OSes, indeed all embedded OSes I know allow device drivers to
completely bypass kernel services. Most embedded OSes like Nut/OS and
eCos even allow user code to directly access hardware without even
going through device drivers.
Barry
2007-07-18 22:25:00 UTC
Permalink
<< snip>>
Post by ***@yahoo.com
Most OSes, indeed all embedded OSes I know allow device drivers to
completely bypass kernel services.
So your knowledge is incomplete. But most of your statements are quite
valid.
Post by ***@yahoo.com
Most embedded OSes like Nut/OS and
eCos even allow user code to directly access hardware without even
going through device drivers.
gursharan
2007-07-18 22:01:38 UTC
Permalink
Post by u***@gmail.com
Instead looking for plce of kernel into Any O.S. It is better to
think. Why do we need kernel.....
Kernel is used for the interface between utility programs and device
drivers...Kernel consists of software programs used to inteconnect
higher and lower layers.
1. Kernel manage system resources between hardware and software.
2. It provides lowest level of abstraction with system calls,
commands..
-----------------------------------------------------------
| Application |
--------------------------------------------------------------
| Kernel |
----------------------------------------------------------------
| CPU | Memory | Devices |
---------------------------------------------------------------
I cant see any hardware abstraction layer (also called the OEM layer),
that would have kernel and other system level s/w stuff on its top? I
Barry
2007-07-17 04:25:17 UTC
Permalink
Post by k***@kaxy.com
We have been having discussions lately regarding software architecture
layering for our embedded system. My architect has come up with a
layering diagram that starts from the hardware layer (i.e. layer 1).
Immediately above the hardware layer (i.e. at layer 2 level) he shows
2 layers ---- the kernel and the device driver layer. Additionally, a
sliver of the device driver layer is shown below the kernel layer,
implying the dependence of the kernel on the device drivers.
Now all this is hunky dory except that I disagree with showing the
kernel immediately above the hardware layer. How can the kernel
reside immediately above the hardware? I think that the kernel will
never be immediately above the hardware layer. It will always be
above the device driver layer. Without device drivers, the kernel
software cannot execute on the hardware platform. I would like to
redraw the layering diagram showing the kernel sitting totally on top
of the device driver layer. What do you say?
I am showing the two layering diagrams below. Kindly copy them into
notepad and view them there. Alternatively change the font to a fixed
width font. Any insight will be appreciated.
Thanks,
Bhat
_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| ______| |
| Kernel | Device |
| | Drivers |
|____________|____________|
| |
| Hardware |
|_________________________|
Architect's view
_________________________
| |
| Higher Layers |
| (not shown here) |
|_________________________|
| | |
| | |
| Kernel | |
|__________________| |
| |
| Device Drivers |
|_________________________|
| |
| Hardware |
|_________________________|
My view
It would be impossible to answer the question without knowledge
of the physical architecture and intended use of the system in question.
The distinction of "device driver" as opposed to "kernel" in particular.
On some designs they are completely separate and communicate by a
defined interface. On others they are intermingled and difficult
to distinguish.
Loading...