Haiku Kernel Architecture Questions

Hello,
I can’t seem to find any in-depth documentation on the Haiku kernel,
other than that it was forked from NewOS and that it is very BeOS
like. I am interested in how the kernel differs from the BeOS kernel
and other kernels in general. I know that the network stack in
integrated in the kernel, but do the other servers still run in user
space? I have read that the BeOS kernel was not a real microkernel in
the sense that some drivers ran in the kernel, is this the same with
the Haiku kernel? How does the Haiku kernel perform compared to BeOS
or a monolithic kernel like Linux or the BSD kernels?

If any of you guys could point me in the direction of some
documentation that answers these questions it would be much
appreciated.

Thanks,
John

Wikipedia is a good source of information to help you get started. There are many keywords below that you can search for and get more information on.

The main 3 are the Monolithic, Microkernel & Hybrid Kernels. I find OSes based on Hybrid Kernels the most responsive and best ones out there.

The Hybrid Kernel is a mix of Monolithic & Microkernel - takes the best from each to improve performance and avoid the drawbacks.

OSes with Hybrid kernels are:
BeOS, Haiku, Mac OSX, Windows NT/2000/2003/XP/Vista, ReactOS

AmigaOS is a very fast OS and influenced BeOS, AROS, MorphOS, Atheos/Syllable.

AmigaOS and MorphOS use microkernels which works terrific for them. People are always impressed with the speed of these two compact OSes. Small microkernels are really fast and very efficient. Large microkernels experience performance issues and reason why large OSes avoid them.

OSes with monolithic kernels: Linux, MS-DOS, Windows 9x/Me, Mac OS 8.6 & earlier

Microkernels work excellent with small, simple, tight kernels. They give responsiveness and avoid performance penalties on small kernels. Monolithic are suited for large, complex kernels and provide better performance compared to Microkernels on big kernels BUT the Hybrid Kernel is the best choice for large kernels and gives better performance and responsiveness compared to the other 2. It should fair pretty well against the Microkernel on small kernels too.

Both Microsoft and Apple moved from Monolithic to Hybrid Kernels with their newer based OSes. That tells us they understand Hybrid provides the best performance and choice for large kernels.

Haiku kernel is not finished until R1 is reached. By that time I expect it to be better optimized and improved with performance that rivals BeOS and Linux.

Big Linux drawbacks from technical perspective:

  1. Still uses Monolithic kernel. You’ll notice that many modern day OSes that are considered to be very fast and responsive use the Hybrid Kernel ( for large kernels ) or Microkernel ( for small kernels ). Linux should switch to Hybrid Kernel design to improve performance but Linus is too stubborn to convince.

  2. Linux is disjointed - bunch of parts thrown together. You have one group that does the Kernel. Another creates the X Window system. Then a few other groups do the Window Managers ( KDE, Gnome, Xfce, IceWM, Fluxbox, etc. ). And they use different APIs too. Gnome uses GTK+ & KDE uses Qt. Because these people do not work closely together with one another - you can tell that Linux does not feel smooth - yes it works good but lacks quality finish. And the way it is currently developed, through seperation, impacts performance too.

Haiku should perform and feel better than Linux because it uses a Hybrid Kernel which gives certain advantages. And 2nd, the kernel, GUI, WM are all tightly integrated - created from the same developers and APIs - makes it look and feel complete and perform well.

Linux definitely uses kernel threads for many things now if you look closer, so it’s not that far of other hybrid kernels.

AmigaOS is a beast on its own. Yes it was designed like a microkernel, with each device and filesystem having their own thread (task), but it doesn’t actually have any enforced boundary between userland and kernel land, nor memory protection, which greatly lowers the latency. It’s like a single kernel process running each app as a different thread in the kernel.

Well, I was using Wikipedia for reference and they classify AmigaOS as Atypical Microkernel. :slight_smile:

Basically a form of Microkernel that differs ( somewhat ) from the standard Microkernel structure. http://en.wikipedia.org/wiki/Amigaos

Linux is classified as Monolithic in structure. http://en.wikipedia.org/wiki/Linux

Linux could be closer to Hybrid but it still follows a monolithic kernel architecture.

I also recall there was a discussion with Linus and Andrew Tanenbaum. Linus was making the argument for Monolithic kernels and Andrew was saying the Linux should move towards Microkernel ( or hybrid kernel? ).

Also, Linus Torvalds said of this issue:

“As to the whole ‘hybrid kernel’ thing — it’s just marketing. It’s ‘oh, those microkernels had good PR, how can we try to get good PR for our working kernel? Oh, I know, let’s use a cool name and try to imply that it has all the PR advantages that that other system has’.”

Linus never believed in Hybrid or Microkernels so I doubt Linux will ever go that route. They’ll do what they can to improve Monolithic but there are limits to what can be achieved. Microsoft & Apple realized this and switched over to Hybrid Kernels. Many other performance OSes use Hybrid or in about 2 or 3 cases Microkernels.

I totally agree with you about Linux, even Ubuntu, “Linux for Human Beings” is a massive tangled mess that is a nightmare for regular people to update and maintain. I have always been on the Tanenbaum side of the Microkernel vs. Monolithic debate, I mean who wants to rehash 1970’s kernel architecture design when you had Mach running on multiple processors? Granted it was slower, but it ran on multiple processors and had multithreading, and that always interested me. I think that for a Desktop operating system however, the BeOS always had the perfect design and that even though I was skeptical at first, I am glad that Haiku has kept this tradition. I think that once the Alpha is release it will really start to stir up some interest in Haiku, I think it is time for me to dust off my Be Programming books and start writing apps!

John

John said on ml:
“There is nothing worse that upgrading a Linux kernel only to have it break nvidia, vmware drivers, etc. Then after you rebuild everything you get scolded every time you boot that the kernel is tainted.”

I’ve had this happen to me too. And, I built a system for my parents using Geforce video card but the Nvidia drivers would not work because of new kernel & Xorg server in Fedora. One day I decide to update my Fedora system and then Realplayer stops working ( from new library? ), etc., etc.

Linux works great when you use an older version, don’t update the kernel and avoid 3rd party drivers.

Linus and Andrew were both wrong because Hybrid Kernel is the way to go. :slight_smile: It combines the best from both monolithic and microkernel.

BeOS also created their code for i586 systems. Haiku does the same. They decided better to not support the older i386 like Linux. This should help with code and machine optimization. ( faster code ).

Alpha should get excitement going in the Haiku community and attract more users and devs. Many are hoping for a 2008 release. Alpha should spark some greater interest in Haiku.

You actually don’t have to start from scratch for apps. You can always improve or fix other BeOS software out there or even port over POSIX apps., Quite a few open source projects to choose from. Look at Sourceforge, BeBits, and OSDrawer.

Yeah, Microkernels are cool, but for a high performance desktop machine, you can’t afford to waste CPU cycles on the overhead, especially if its just to keep the machine from crashing every once in awhile.

well you know how it is. People take the path of least resistance as long as they can until they are forced to change. Linux is the open source leader on the desktop so they are in no hurry to rewrite anything.
Same is true for firefox. Webkit is smaller and faster than gecko but mozilla won’t switch until another webkit browser really smacks it around.

I have tried many OSes and currently I have six installed.
Every system / kernel is good in the domain it was designed for.

Linux was, is and will be the monolithic kernel.
However, Linux was born in the GNU project, which uses its own micro-kernel - GNU mach. Some other reincarnations of the GNU/Hurd use L4 etc - all they are micro-kernels.

As of monolithic kernel, at least one big OS uses it - Sun Solaris, and doesn’t attempt to switch to anything other then that.

“The Hybrid Kernel is a mix of Monolithic & Microkernel - takes the best from each to improve performance and avoid the drawbacks.”

Since you’ve already quoted Linus Torvalds, who actually knows enough about this to have written his own operating system kernel, and then you disagree with him - maybe you can explain what it is about Haiku’s design that makes it a “hybrid” and proves him wrong. For example, how does Haiku avoid the most obvious and serious drawback of a monolithic design, the fact that a bug in a filesystem, network protocol, or hardware driver can crash the OS or corrupt unrelated data ?

In fact can you point at any specific feature or set of features of Haiku and say “that’s why it’s a hybrid” ? If you struggle to do that, don’t you think you should re-evaluate your certainty that Haiku is a “hybrid” and even that this category exists ?

You say that OS X is an example of a “hybrid”. OS X runs as a single privileged OS server on top of the XNU microkernel. Apple got their experience of this approach by porting Linux to run on Mach in the same way, the result was MkLinux, the Linux kernel running as a privileged OS server on Mach on Apple PowerPC machines. MkLinux was not considered a success (people not unreasonably preferred faster cheaper native Linux on x86), but Apple’s engineers used what they’d learned when rushing to mash bits of FreeBSD, NeXT and other components together into what became OS X. Today’s Linux distributions for PowerPC don’t use MkLinux, but instead a perfectly conventional port of Linux to the native PPC hardware.

If that’s what a “hybrid” is then MkLinux was there in 1996, nobody was very impressed, and also, Haiku doesn’t resemble this design at all, it doesn’t have a microkernel (whether Mach, or L3 or custom built) underneath, it runs on the bare metal just like other monolithic OS kernels.

the biggest difference is that haiku has a stable kernel driver API. Drivers don’t need to be in the kernel source tree so it is easier for the hardware company or other outsiders to develop and distribute drivers

basically what you are getting from a more hybrid approach is more flexibility.

You mean Linus who used the MINIX microkernel as his guide to write the Linux kernel? The guy that believes he is right about everything? The person that wasn’t sure what he was doing with Linux to start with and was asking everyone for help? Suddenly he knows it all and that’s why Linus constantly changes the Linux kernel and breaks compatibility with drivers?

Haiku is not even Alpha and you put it down. Well, just a little info for you. Linux took many years before people even looked at or used it and to even get to where it is today. You really think Linux was perfect from the get go? It wasn’t! Can you at least wait till R1 before you become so critical? Maybe too hard for you? Haiku will have many changes made by the time R1 comes out.

All the information is on Wikipedia. Look up:

  1. Hybrid Kernel - it will even show OS examples
  2. Then look up specific OSes: BeOS, Windows XP, Mac OSX, Haiku

You’ll see they are all classified as Hybrid Kernels. Maybe you don’t understand this? Wikipedia entry on Hybrid Kernel gives a decent explanation and even a picture to make it easy for you to understand.

To get you started I even give you the first link:

The only modern day, big OSes still stuck using monolithic are Unix/Linux/BSD type OSes. All modern performance based OSes use Hybrid ( or in a few cases Microkernel ). Look them up on Wikipedia.

Just because Linus likes monolithic doesn’t mean everyone agrees. For one, Professor Andrew who wrote the microkernel MINIX OS and I recall there were others too who said Linus was wrong. Go tell it to those that program OSes with Hybrid kernels and see what they have to say. And if monolithic is so great then why have so many OSes embraced Hybrid for the future???

I’m not going to debate this back & forth with you. You can look at Wikipedia and it’ll tell you which OS uses what kernel type. Microsoft and Apple abandoned monolithic for Hybrid and Linux/Unix/BSD are the only ones still stuck using the old monolithic style. If you believe it’s good then stick with it while everyone passes you by.

This is not a new discussion, and NoHaikuForMe is not new to this topic :wink:

Pointing to the wikipedia article on Hybrid Kernels doesn’t help, since the article on Monolithic Kernels pretty much overlaps a lot of the same crap anyway.

For some reason, the definition of “monolithic Kernel” has evolved to mean a a kernel and drivers that all run in the same memory space (rather than “one large binary” as the definition of “monolithic” would lead one to believe), thus, now “monolithic kernel” by wikipedia definition includes any kernel with loadable modules that might even run on multiple threads. Ultimately, I’m guessing it’s just become a pissing match - it’s not even worth arguing anymore.

There are definitely parts of Haiku that run outside kernel space… such as the app_server (and thus, the video accelerants), the input_server, the print_server, and a few other pieces. These parts are not “applications” in the same sense - as they’re essentially layers upon the kernel which talk to the hardware drivers through protocols that abstract the rest of the system from them.

here’s the source of the quote:
http://www.realworldtech.com/forums/index.cfm?action=detail&id=66630&threadid=66595&roomid=2

The point I wanted to make:
Two big OS companies, Microsoft & Apple have moved over to using Hybrid Kernels plus quite a few other OSes have done the same. Somehow these two big players were convinced and I’m sure they have very smart programmers working for them.

Now, I trust these multi-billion dollar companies more than I do Linus. He can continue to yell, scream, rant and rave how great monolithic kernels are but the reality is almost all non-Unix type OSes have moved onto Hybrid Kernels and it seems to be working for them.

Look how well Windows 2000/XP worked out for Microsoft with a hybrid kernel. It runs very good though they really messed up by not placing registry restrictions ( bloats over time ).

What does it tell you when only Linux/BSD/Unix is still stuck with monolithic kernels? Either they know something no one else does ( very unlikely ) or they just don’t want to change over. I’d rather go with an OS with Hybrid Kernel like those used in XP & Mac OSX - shows that this is the right direction. Even BE Inc, a multi-million dollar company, opted for hybrid kernel in BeOS because they realized it was the better overall choice.

Who do you trust to be right? Linus or Microsoft+Apple?

can you explain why hybrid = “runs good”? I don’t think it has anything to do with performance. Hybrid is not that much different than monolithic.

on the other hand, nobody considers microkernel anymore for general purpose OS as they are just too slow.

Sure arielb, I’ll explain & provide links for more details.

Monolithic vs Microkernels
-monolithic: has the best/optimal performance. In tests, against L4 microkernel, Linux peformed 6-7% faster. When compared to MINIX, Linux ran 5-10% faster. B/c microkernel takes almost everything out of kernel space & puts it into user space - it takes a performance hit.

-microkernel:

  1. MUCH LESS code in the kernel - Linux has 2.5 Million lines of code compared to under 4,000 for MINIX = less likely to have “bugs” get into the kernel code
  2. Greater Stability from crashing ( from bugs & bad drivers )
  3. Greater Security against Hackers
  4. Better efficiency because of greater separation
  5. More flexible because of modular design

The only advantage monolithic has over microkernels is better performance.

The hybrid kernel takes some concepts from monolithic ( to maintain similar performance level ) and microkernel to improve overall system stability. That’s what I mean by runs good - very close performance to monolithic kernel. With hybrid kernel, it should bench very close to monolithic while obtaining, to a certain degree, the advantages listed above that microkernel has to offer. Microkernel sacrificed performance for stability. Monolithic sacrifices stability for performance. Hybrid gives comparable performance to monolithic with much better stability.

Looking at: http://en.wikipedia.org/wiki/Image:OS-structure2.svg

You see that the Hybrid model has moved the File & Unix Servers to user mode. This means, less code in the kernel itself, since these are moved out = smaller kernel = less bugs & easier to maintain. Also, stability would be improved because if these servers crashed then they could easily be restarted and not take down the whole system either. The rest stays in kernel mode and benefits from increased performance.

“This design ( hybrid kernel ) combines the monolithic and microkernel design in that it has characteristics of both. It keeps some subsystems in kernelspace to increase performance, while keeping others out of kernelspace to improve stability.”
from here: http://www.osnews.com/files/17537/kernel_designs_explained.pdf

http://daniel.carrera.name/2008/09/02/minix-3

http://www.embedded.com/columns/embeddedpulse/189500560

The term “modular monolithic” seems to describe Haiku’s kernel best; I don’t like the term “hybrid”: the only meaningful difference between monolithic and microkernel is if drivers get individual memory spaces, and hybrid works like monolithic here.
Linux and Haiku are both modular monolithic, Haiku may have a better kernel-driver API, but that’s not enough to create a new term “hybrid”.

Because of the networking code inserted into Haiku’s kernel, does that make Haiku a monolithic or hybrid architecture? I don’t imagine it can still be classified as a microkernel, anymore, can it?

well i havn’t bothered to read all of the above but enough to see no one has mentioned the exokernel…

basically they are just a hardware abstraction layer and the apps can either use that directly or use a libos (or both i guess or a combination of different libos) to achieve extremely high proformace (mainly due to the the exokernel only providing acces to the HW instead of trying to manage the processes also which it has no knowlege of)

MIT was researching them but apparently they have slacked off on it… thing is i havn’t heard any drawbacks for them… also I think it is somewhat similar to what freebsd (I think that is the right one) emulates Linux compatibility except they implement it on top of a fully capable kernel instead of a thin HW abstraction layer so i reckon they lost a bit of proformance from that…

The only advantage monolithic has over microkernels is better performance.

well that is very important to linux so you can’t exactly say that it is stuck in the past for this decision.

Stability. Linus wrote:
"The whole argument that microkernels are somehow “more
secure” or “more stable” is also total crap. The fact that
each individual piece is simple and secure does not make
the aggregate either simple or secure. And the
argument that you can “just reload” a failed service and
not take the whole system down is equally flawed.

Anybody who has ever done distributed programming should
know by now that when one node goes down, often the rest
comes down too. It’s not always true (but neither is it
always true that a crash in a kernel driver would bring
the whole system down for a monolithic kernel), but it’s
true enough if there is any kind of mutual dependencies,
and coherency issues."

I agree but this also hits linux back. The real problem for linux is that it is just a kernel and not a complete system. So what if the kernel is stable? If X, gtk, gnome and all the other stuff a distro adds has problems, your app still goes down and you’re screwed.

In Haiku, all the OS components are built together in one place. It’s a lot easier to test one complete system than a potentially infinite number of linux distributions.