What is the role of a kernel?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

What is the role of a kernel?

Post by cxzuk »

What is the role of a kernel in your opinion?

There is a lot of bootloaders that are doing alot of things.. and as most projects here are microkernels, there are alot of drivers doing alot of things too.

So what things have you left in your kernel and why did you do it that way?

Mike
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: What is the role of a kernel?

Post by NickJohnson »

From a technical standpoint, I would consider the kernel any part of the operating system that persistently runs in the highest privilege level. This makes it fundamentally a processor driver: all processor features (interrupts, memory protection, multitasking) have to be handled in some way by the kernel (even if policy is exported,) because those features have to be limited to the highest privilege level.

In my kernel, which I personally consider a microkernel, the only things in the kernel pertain to interrupts, system calls, basic IPC, and multitasking (with threading), including memory manager and scheduler policy. All device drivers run as processes with port I/O privileges. Message queueing and verification, executable loading, and the VFS (which is distributed) are part of the C library.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: What is the role of a kernel?

Post by quanganht »

Looks like u missed a lot of readings. Please check the Wiki.
"Programmers are tools for converting caffeine into code."
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: What is the role of a kernel?

Post by rdos »

What is in kernel, and what is in device-drivers have changed over time. Lately, the reason for this has to do with size limitations (kernel getting above 64k). What currently is in kernel is application / process management, scheduler, linear and physical memory management, GDT/LDT descriptor management, interrupts, handle management, paging, gate management (basically). I also have a driver called "util" that contains essential functions that used to be in kernel (IO, multiple-wait interface, environment, random number generator, CRC-calculation). The last time when the SMP scheduler overflowed kernel, I had trouble move more modules as they had too strong dependencies, so I instead removed macros from the scheduler and replaced them with procedures to save space. I suppose that the kernel set of functions left in kernel are things that are hard to separate.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: What is the role of a kernel?

Post by rdos »

In my design, both kernel and device-drivers runs in priviledged mode. There is no support for running device-drivers at ring 3. Protection and isolation is instead enforced with segmentation.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What is the role of a kernel?

Post by Solar »

If you break it down to the smallest common denominator, the role of a kernel is to do those things that require supervisor / ring 0 privileges.

Depending on your design, that might be very little (microkernels), or very much (macrokernels). (Ignoring exokernels for the moment since they were only invented to complicate discussions like this one anyway. :twisted: )
Every good solution is obvious once you've found it.
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: What is the role of a kernel?

Post by cxzuk »

Thankyou for your replies :)

Yes, The general opinion seems to be the same which is good.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re: What is the role of a kernel?

Post by Colonel Kernel »

I will disagree a bit with the general opinion that kernel == privileged mode by providing a counterexample: Singularity. By default in Singularity, the kernel and all processes run in privileged mode, but software isolation is used to keep the processes from stomping each other or the kernel. There is still a system call API in Singularity, but by default no privilege level change is required to call it (you can run processes in ring 3, but this is configurable).

The key point is that the system call API is a trust boundary, regardless of how it's implemented. You could define the kernel more generally as the part of the OS that is fully trusted to manage processes and hardware resources. The granularity of resource management is really what gets you into the micro-verus-monolithic spectrum (from just interrupts and the MMU to all device drivers in the system).
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What is the role of a kernel?

Post by Solar »

Just bunch up Singularity with exokernels, git, and that very specific customer of ours that insists on having our software running on AIX: Things that complicate matters and are going on my nerves. :twisted:
Every good solution is obvious once you've found it.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: What is the role of a kernel?

Post by rdos »

Colonel Kernel wrote:The key point is that the system call API is a trust boundary, regardless of how it's implemented. You could define the kernel more generally as the part of the OS that is fully trusted to manage processes and hardware resources. The granularity of resource management is really what gets you into the micro-verus-monolithic spectrum (from just interrupts and the MMU to all device drivers in the system).
I like it. Then I can define my system as a micro-kernel with two isolation barriers. The first one is the device-driver API, which all device-drivers are allowed to use, and the second one is the application API, which device-drivers and ring 3 applications are allowed to use. :twisted:

I suppose I could even move device-drivers to ring 1 or 2 if I wanted to. The only reason not to do it would be complicating interrupts with ring-switches. Or a device-driver could alias its interrupt handler code to ring 0 for ISR handlers, and run the rest of the code at ring 1 or 2.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: What is the role of a kernel?

Post by Rusky »

This probably just complicates issues more (obligatory :twisted:) but capability-based systems have a very different idea of trust. Every piece of the system is trusted with exactly what it needs (i.e. POLA to the max), so there are any number of barriers from the kernel to the device drivers and all the way out to any part of the system you like.

You could even imagine a processor that would make a kernel completely unnecessary- it would just hand off all the resources in the system to the equivalent of /bin/init, which would handle booting and then be rather unnecessary. IPC and such wouldn't need to be mediated by a central authority because init would have given out either address space handles or os-implemented process handles wherever they're needed.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What is the role of a kernel?

Post by Solar »

That is the basic idea of an exokernel (discussed above), isn't it?
Every good solution is obvious once you've found it.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: What is the role of a kernel?

Post by Rusky »

Capability-based systems use interfaces to resources that look like objects with a collection of supported operations. You can replace the implementation but implement the same interface (see Unix file handles as an example). Exokernels focus more on the permission part, and there's still a central, trusted kernel. They're a bit different from what I'm describing, but the actual implementation is probably the same.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re: What is the role of a kernel?

Post by Colonel Kernel »

Solar wrote:Just bunch up Singularity with exokernels, git, and that very specific customer of ours that insists on having our software running on AIX: Things that complicate matters and are going on my nerves. :twisted:
I'm just making sure people remember the difference between concepts and implementation details. Hardware privilege level is an implementation detail. "Microkernel" is a concept. Defining one in terms of the other is a classic design mistake. ;)
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
Post Reply