Hybrid kernel, not NT

By: Linus Torvalds (torvalds.delete@this.osdl.org), May 9, 2006 4:19 pm
Room: Moderated Discussions
Andi Kleen (ak-rwt@muc.de) on 5/9/06 wrote:
>
>Traditional unix has the uarea per process which is
>normally not accessible by other processes afaik.

The data is accessible. It may be mapped at a
magic location so that it virtually shows up at a fixed
address when you're running within that MM context,
but that's no different from user pages, really. It's
just not writable by the user (sometimes it is readable).

So it doesn't really change the argument. The kernel
and user space generally share one address space (but with
different access rules), but different processes do not.

IOW, the uarea is just another access space, and your
address space has three of them: "kernel", "user" and
"uarea", with different access rules. There's nothing
that says that you can't have more of them, or that you
can't use VM tricks for various implementation details.

(Other processes can access your uarea, but if
you play VM games with it, those processes obviously
need to access it with special care, by going through
the physical address. I don't think really traditional
UNIX actually played any VM tricks at all, and it was
just another kernel data structure with a perfectly
ordinary pointer to it).

It's true that broken hardware may enforce yet other
access spaces (most notably on x86 due to limited
virtual address space, causing some physical memory to
have to be accessed through a separate thing), but that's
not something you'd design for, that's somethng where you
design around bad hardware.

That's not very different (in some respects) from other
hardware access spaces. Usually you have to access IO in
specific ways too. It's just sad when you have to access
memory through games (it was sad in the highmem.sys sense
in 1990, and it was sad in the x86 CONFIG_HIGHMEM sense in
2000).

>To be fair even in monolithic kernels it is not easy
>to share data given races on SMP/preemption etc.

Nobody claims that threaded programming is easy.

But it is a hell of a lot easier if you can use a lock
and access shared data than if you have to use some
insane distributed algorithm. It's usually many orders
of magnitude easier in monolithic kernels.

Synchronizing some data in a monolithic kernel may
involve using a lock, or special instructions that do
atomic read-modify-write accesses. Doing the same in
a microkernel tends to involve having to set up a whole
protocol for communication between the entities that
need to access that data, or complex replication schemes
(or they just end up mapping it into every process space,
just to avoid the problem. Problem solved, by just
admitting that separate address spaces was a mistake)

>Usually you need to design a locking protocol, care
>about livetime issues etc. It's all not simple there
>neither.

Nobody says kernels are easy. We're talking purely about
the relative costs. And microkernels are harder.
Much harder.

>I always admired how elegant some of parallel Erlang
>programs look and they use message passing
>so you certainly can do some stuff cleanly with
>messages too.

Not efficiently, and not anything complex.

It's easy and clean to use messages if you don't have
any truly shared data modified by both entities.

But the whole point of a kernel tends to be about shared
data and resources. Memory pressure? How do you free
memory when you don't know what people are using it for?

You can try to do an OS in Erlang. Be my guest. I'll be
waiting (and waiting.. The point being - you can't do
a good job).

Let's try an analogy. I'm not sure it's a great analogy,
but whatever:

In the UNIX world, we're very used to the notion of having
many small programs that do one thing, and do it well. And
then connecting those programs with pipes, and solving
often quite complicated problems with simple and independent
building blocks. And this is considered good programming.

That's the microkernel approach. It's undeniably a really
good approach, and it makes it easy to do some complex
things using a few basic building blocks. I'm not arguing
against it at all.

BUT IT IS NOT REALISTIC FOR ALL PROBLEMS. It's a really
really good way to solve certain problems. I use
pipelines all the time myself, and I'm a huge believer.
It works very well indeed, but it doesn't work very well
for everything.

So while UNIX people use pipelines for a lot of important
things, and will absolutely swear by the "many small
and independent tools", there are also situations where
pipelines will not be used.

You wouldn't do a database using a set of pipes, would you?
It's not very efficient, and it's no longer a simple flow
of information. You push structured data around, and you
very much will want to access the database directly (with a
very advanced caching mapping system) because not doing so
would be deadly.

Or, to take another example: you may well use a typesetting
system like LaTeX in a "piped" environment, where one tool
effectively feeds its input to another tool (usually through
a file, but hey, the concept is the same). But it's not
necessarily the model you want for a word processor, where
the communication is much more back-and-forth between the
user and the pieces.

So the "many small tools" model works wonderfully well,
BUT IT ONLY WORKS FOR A NICELY BEHAVED SUBSET OF YOUR
PROBLEM SPACE. When it works, it's absolutely the right
way to do things, since you can re-use components. But
when it doesn't work, it is just a very inconvenient
model, and while it's certainly always possible to
do anything in that model (set up bi-directional sockets
between many different parts), you'd have to be crazy to
do it.

And that's a microkernel. The model works very well for
some things. And then it totally breaks down for others.

And the problem with a kernel is that it should do
everything users want it to do. Not just the easy cases
that match the developement model.

>How would you describe AmigaOS then? It had a quite
>microkernelish structure, but no address space
>separation.

It was not a microkernel. Exactly because it lacked
the one thing that makes a microkernel: separate
access spaces.

It didn't even really do message passing. It had interfaces
that looked like message passing, and it tried to
make them clean, but it really was just pushing pointers
around.

In short, AmigaOS really has nothing at all to do with
microkernels at any fundamental level. Paying lip service
to message passing and looking like a microkernel at that
level doesn't really make it so.

Now, message passing is a perfectly valid model. And in
the absense of memory protection, it's even a pretty
efficient model. But it doesn't mean "microkernel"
per se. Message passing just means "message passing".

>There is an old quote from L.Lamport that
>fits very well (paraphrased):
>"Distributed computing means that you cannot get your
>work done when some computer you never heard of crashes"

Absolutely. That's the microkernel model.

Linus
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Hybrid (micro)kernelsTzvetan Mikov2006/05/08 03:41 PM
  Hybrid (micro)kernelsS. Rao2006/05/08 05:14 PM
  Hybrid (micro)kernelsBill Todd2006/05/08 05:16 PM
    Hybrid (micro)kernelsTzvetan Mikov2006/05/08 06:21 PM
      Hybrid (micro)kernelsnick2006/05/08 06:50 PM
      Hybrid (micro)kernelsBill Todd2006/05/09 12:26 AM
        There aren't enough words...Rob Thorpe2006/05/09 01:39 AM
          There aren't enough words...Tzvetan Mikov2006/05/09 02:10 PM
            There aren't enough words...Rob Thorpe2006/05/14 11:25 PM
        Hybrid (micro)kernelsTzvetan Mikov2006/05/09 10:17 AM
          Hybrid (micro)kernelsBill Todd2006/05/09 03:05 PM
  Hybrid (micro)kernelsrwessel2006/05/08 10:23 PM
    Hybrid kernel, not NTRichard Urich2006/05/09 05:03 AM
      Hybrid kernel, not NT_Arthur2006/05/09 06:06 AM
        Hybrid kernel, not NTRob Thorpe2006/05/09 06:40 AM
          Hybrid kernel, not NT_Arthur2006/05/09 07:30 AM
            Hybrid kernel, not NTRob Thorpe2006/05/09 08:07 AM
              Hybrid kernel, not NT_Arthur2006/05/09 08:36 AM
                Linux vs MacOSX peformance, debunked_Arthur2006/05/18 06:30 AM
                  Linux vs MacOSX peformance, debunkedRob Thorpe2006/05/18 07:19 AM
                    Linux vs MacOSX peformance, debunkedAnonymous2006/05/18 11:31 AM
        Hybrid kernel, not NTLinus Torvalds2006/05/09 07:16 AM
          Hybrid kernel, not NTAndi Kleen2006/05/09 01:32 PM
            Hybrid kernel, not NTmyself2006/05/09 02:24 PM
              Hybrid kernel, not NTmyself2006/05/09 02:41 PM
              Hybrid kernel, not NTBrendan2006/05/09 04:26 PM
                Hybrid kernel, not NTLinus Torvalds2006/05/09 07:06 PM
                  Hybrid kernel, not NTBrendan2006/05/13 12:35 AM
                    Hybrid kernel, not NTnick2006/05/13 03:40 AM
                      Hybrid kernel, not NTBrendan2006/05/13 08:48 AM
                        Hybrid kernel, not NTnick2006/05/13 06:41 PM
                          Hybrid kernel, not NTBrendan2006/05/13 08:51 PM
                            Hybrid kernel, not NTnick2006/05/14 04:57 PM
                              Hybrid kernel, not NTBrendan2006/05/14 09:40 PM
                                Hybrid kernel, not NTnick2006/05/14 10:46 PM
                                  Hybrid kernel, not NTBrendan2006/05/15 03:00 AM
                                    Hybrid kernel, not NTrwessel2006/05/15 06:21 AM
                                      Hybrid kernel, not NTBrendan2006/05/15 07:55 AM
                                        Hybrid kernel, not NTLinus Torvalds2006/05/15 08:49 AM
                                          Hybrid kernel, not NTnick2006/05/15 03:41 PM
                                          Hybrid kernel, not NTtony roth2008/01/31 01:20 PM
                                    Hybrid kernel, not NTnick2006/05/15 05:33 PM
                                      Hybrid kernel, not NTBrendan2006/05/16 12:39 AM
                                        Hybrid kernel, not NTnick2006/05/16 01:53 AM
                                          Hybrid kernel, not NTBrendan2006/05/16 04:37 AM
                  Hybrid kernel, not NTAnonymous2008/05/01 09:31 PM
                    Following the structure of the treeMichael S2008/05/02 03:19 AM
                      Following the structure of the treeDean Kent2008/05/02 04:31 AM
                        Following the structure of the treeMichael S2008/05/02 05:02 AM
                        Following the structure of the treeDavid W. Hess2008/05/02 05:48 AM
                          Following the structure of the treeDean Kent2008/05/02 08:14 AM
                            Following the structure of the treeDavid W. Hess2008/05/02 09:05 AM
                              LOL!Dean Kent2008/05/02 09:33 AM
                              Following the structure of the treeanonymous2008/05/02 02:04 PM
                                Following the structure of the treeDean Kent2008/05/02 06:52 PM
                                Following the structure of the treeFoo_2008/05/03 01:01 AM
                                  Following the structure of the treeDavid W. Hess2008/05/03 05:54 AM
                                    Following the structure of the treeDean Kent2008/05/03 09:06 AM
                                      Following the structure of the treeFoo_2008/05/04 12:06 AM
                                        Following the structure of the treeMichael S2008/05/04 12:22 AM
            Hybrid kernel, not NTLinus Torvalds2006/05/09 04:19 PM
              Microkernel Vs Monolithic KernelKernel_Protector2006/05/09 08:41 PM
                Microkernel Vs Monolithic KernelDavid Kanter2006/05/09 09:30 PM
                  Sigh, Stand back, its slashdotting time. (NT)Anonymous2006/05/09 09:44 PM
                  Microkernel Vs Monolithic Kernelblah2006/05/12 07:58 PM
                  Microkernel Vs Monolithic KernelRob Thorpe2006/05/15 12:41 AM
          Hybrid kernel, not NTAnalGuy2006/05/16 02:10 AM
            Theory versus practiceDavid Kanter2006/05/16 11:55 AM
              Distributed algorithmsRob Thorpe2006/05/16 11:53 PM
              Theory versus practiceHoward Chu2006/05/17 01:54 AM
                Theory versus practiceJS2006/05/17 03:29 AM
          Play online poker, blackjack !!! Gamezonex2007/08/16 12:49 PM
  Hybrid (micro)kernelsphilt2006/05/14 08:15 PM
    Hybrid (micro)kernelsLinus Torvalds2006/05/15 07:20 AM
      Hybrid (micro)kernelsLinus Torvalds2006/05/15 10:56 AM
        Hybrid (micro)kernelsRob Thorpe2006/05/16 12:22 AM
          Hybrid (micro)kernelsrwessel2006/05/16 10:23 AM
            Hybrid (micro)kernelsRob Thorpe2006/05/16 11:43 PM
              Hybrid (micro)kernelsrwessel2006/05/17 12:33 AM
                Hybrid (micro)kernelsRob Thorpe2006/05/19 06:51 AM
                  Hybrid (micro)kernelsrwessel2006/05/19 11:27 AM
      Hybrid (micro)kernelstechIperson2006/05/15 12:25 PM
      Hybrid (micro)kernelsmas2006/05/15 04:17 PM
        Hybrid (micro)kernelsLinus Torvalds2006/05/15 04:39 PM
          Hybrid (micro)kernelsColonel Kernel2006/05/15 08:17 PM
            Hybrid (micro)kernelsWink Saville2006/05/15 09:31 PM
              Hybrid (micro)kernelsLinus Torvalds2006/05/16 09:08 AM
                Hybrid (micro)kernelsWink Saville2006/05/16 08:55 PM
          Hybrid (micro)kernelsrwessel2006/05/16 10:31 AM
            Hybrid (micro)kernelsLinus Torvalds2006/05/16 11:00 AM
        Hybrid (micro)kernelsBrendan2006/05/16 12:36 AM
        Hybrid (micro)kernelsPaul Elliott2006/09/03 07:44 AM
          Hybrid (micro)kernelsRob Thorpe2006/09/04 08:25 AM
      Hybrid (micro)kernelsphilt2006/05/15 11:55 PM
        Hybrid (micro)kernelspgerassi2007/08/16 06:41 PM
  Another questionable entry on Wikipedia?Chung Leong2006/05/18 09:33 AM
  Hybrid (micro)kernelsisrael2006/05/20 03:25 AM
    Hybrid (micro)kernelsRob Thorpe2006/05/22 07:35 AM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell avocado?