# FreeBSD's monolithic kernel



## j4ck (Nov 14, 2015)

I'm studying operating systems and kernel types. In all references that I have read, monolithic kernels are known for being cumbersome, difficult to maintain, difficult to debug, coding in kernel is very challenging, a faulty part of kernel can bring down the whole system and so on ... .
On the other hand, hybrid kernels and micro-kernels have solved these problems. I wonder why FreeBSD uses monolithic kernel? As far as I understand, advantages of a monolithic kernel is limited in 2 or 3 properties: loadable modules, powerful hardware access, easier to implement than other kernel types (I don't agree with this, please let me if iI'm wrong).


----------



## sidetone (Nov 14, 2015)

It's why DragonFlyBSD forked from FreeBSD. Minix 3 also has a hybrid kernel.


----------



## protocelt (Nov 14, 2015)

All kernel designs have both pros and cons. No single design is necessarily better than the other.


----------



## Oko (Nov 14, 2015)

Check out the mailing lists from early nineties for the discussion micro vs monolithic


----------



## drhowarddrfine (Nov 14, 2015)

j4ck said:


> In all references that I have read


You need to get better references. The basis for FreeBSD came out of the same lab Dennis Ritchie and Brian Kernighan and Ken Thompson were in, ATT Labs, along with Unix. Two of those guys still work at Princeton and Google. So I'd like to know the source of your references who say those people are wrong.


----------



## wblock@ (Nov 14, 2015)

j4ck said:


> On the other hand, hybrid kernels and micro-kernels have solved these problems.


In theory, yes, essentially making the kernel into a tiny hypervisor.  In practice, microkernels have problems and tradeoffs of their own.

Anyone who feels that the benefits of a microkernel are useful to them could work on implementing a microkernel for FreeBSD.  So far that has not happened (as far as I know), but it would be a nice alternative to have.  The Minix project appears to be growing, and might be influential in demonstrating a practical microkernel.


----------



## ANOKNUSA (Nov 14, 2015)

j4ck said:


> In all references that I have read, monolithic kernels are known for being cumbersome, difficult to maintain, difficult to debug, coding in kernel is very challenging, a faulty part of kernel can bring down the whole system and so on ... .
> On the other hand, hybrid kernels and micro-kernels have solved these problems.



First thing's first: I'm no hacker. I don't really understand how the internals of an operating system kernel work, so I can't offer any significant insight into how the FreeBSD kernel works relative to others, and if anything that follows is objectively wrong I hope someone will correct me. What I'm fairly certain of, though, is that every major operating system in common use today utilizes a monolithic kernel. The list of "problems" you gave aren't imminent failures that system administrators have to constantly fight off, but rather the limitations of present design. We've had decades to work within and around those limitations, and the thing about kernels is that once they're working well you only occasionally need to make any significant change to them--typically to accommodate next-generation hardware, and since it takes a while for that hardware to become common developers have time to implement drivers and such.

A microkernel design may have offset or eliminated many of the monolithic kernel's limitations, but it's probably a safe guess that since no major OS has adopted a strict microkernel, the benefits simply don't outweigh the effort needed to implement a completely new kernel. Economists and psychologists have long noted that people will stick with whatever they're used to even when something arguably better is available, because the old thing works fine and the myriad costs of adopting the new thing are believed to outweigh the supposed benefits. The QWERTY vs. Dvorak debate is a good example of this.


----------



## Crivens (Nov 15, 2015)

ANOKNUSA said:


> since no major OS has adopted a strict microkernel


QNX comes to mind here.


----------



## tingo (Nov 15, 2015)

The point is: there is a huge difference between theory and practice / real life. Theory is what you study, practice is what you use. This is true for almost any field of study today.
Oh, and people who can convert theory into practice are heroes.


----------



## ANOKNUSA (Nov 15, 2015)

Crivens said:


> QNX comes to mind here.



Can an operating system nobody uses be a "major" one? I didn't even know QNX existed until you posted here...


----------



## sidetone (Nov 15, 2015)

There are a few UNIXes, but they are proprietary. I'm not sure what QNX is.


----------



## Beastie7 (Nov 15, 2015)

ANOKNUSA said:


> Can an operating system nobody uses be a "major" one? I didn't even know QNX existed until you posted here...



Google, Apple, and Blackberry are consumers of QNX. It's a popular real-time embedded OS.


----------



## ANOKNUSA (Nov 15, 2015)

Interesting. Judging by my (admittedly lazy) web searches, though, QNX is incredibly popular in automobile dashboards, and scantly used for anything else. Which is almost certainly why I haven't heard of it, having not owned an automobile in twelve years.


----------

