# Kernel differences between linux and FreeBSD.



## meteorrock (Jun 30, 2013)

I would like to know how the kernels are configured and built on this operating system.

I know all about wiki, and monolithic kernel development. An non obtuse answer would be appreciated. Thanks.


----------



## wblock@ (Jun 30, 2013)

You're in luck, we have a whole Handbook chapter on it: Configuring the FreeBSD Kernel.


----------



## cpm@ (Jun 30, 2013)

Hi,

@wblock@ gave you a great guideline, also if you like learn more about differences between FreeBSD and Linux (include comparison of kernels) is worth reading: Explaining BSD by Greg 'Groggy' Lehey.


----------



## ondra_knezour (Jun 30, 2013)

From developer point of view also FreeBSD Linux kernel cross reference may be worth checking.


----------



## DutchDaemon (Jun 30, 2013)

In other words: http://bit.ly/13fCkg1


----------



## meteorrock (Jul 2, 2013)

Thank you everyone. I will mark this thread as solved.


----------



## RimRunner (Oct 22, 2017)

I have not managed to find any clear and accessible information on the topic so far (many links given on this forum simply go into the details of FreeBSD instead of comparing kernels or they just explain Linux vs. FreeBSD differences at the base system level).

So I try a bit different kind of approach now. I print you a list of different topics about kernel and ask you which parts have the most significant differences between Linux and FreeBSD:

-Process management
-Process scheduling
-System calls
-Data structures (lists, queues, maps, binary trees...)
-Interrupts, their handlers and bottom halves
-Synchronization (of shared resource access)
-Timers and time management
-Memory management
-Virtual filesystem
-File system representation
-The block I/O layer
-Page cache
-Modules
-Kernel objects


----------



## drhowarddrfine (Oct 22, 2017)

RimRunner There are whole books written on those subjects and I'm shocked you couldn't find the answers with Google or the FreeBSD docs. You should buy this book instead.


----------



## RimRunner (Oct 22, 2017)

> "There are whole books written on those subjects and I'm shocked you couldn't find the answers with Google. You should buy this book instead."



As I tried to explain, I was looking for a quick reference on the topic. Naturally one way to learn about this matter is to read Kernel literature on both kernels and then make comparisons. But I thought somebody who already knows both kernels could throw some glues. So far I have find hardly anything like that.


----------



## drhowarddrfine (Oct 22, 2017)

RimRunner You'll have far better luck on the mailing lists and IRC channels where the devs hang out.


----------



## ShelLuser (Oct 22, 2017)

RimRunner said:


> I print you a list of different topics about kernel and ask you which parts have the most significant differences between Linux and FreeBSD:


Counter question: to what end? What are you trying to accomplish here? Reason I ask, as also mentioned by others, is because your question is extremely broad, so it might be better to focus on the actual goal here.

If it's merely educational purposes then Google is your friend, but I'd also like to mention the Developers handbook which is a good source of information on FreeBSD inner mechanics.


----------



## RimRunner (Oct 22, 2017)

ShelLuser said:


> Counter question: to what end? What are you trying to accomplish here? Reason I ask, as also mentioned by others, is because your question is extremely broad, so it might be better to focus on the actual goal here.



I am simply interested in understanding kernels without engaging in studying them seriously at this point (that may come later - I already have those books on Linux & FreeBSD kernels). I may also write an article on FreeBSD one day (for a local hacker mag) and this might be one possible point of view for the text.



> If it's merely educational purposes then Google is your friend.



As I have said, there seems to be no kernel level comparisons on the web, just something more superficial.


----------



## rigoletto@ (Oct 22, 2017)

RimRunner 

The FreeBSD Developer Handbook may have something you like.


----------



## RimRunner (Oct 23, 2017)

gpatrick said:


> As I've already said, understanding the kernel is really not humanly possible when it is 15-20 million lines of code.
> 
> If you really want to understand the kernel, then I would suggest you study Plan 9 or Inferno. Both were created at Bell Labs from some of the same people who created UNIX.



Okay, I meant "to increase my understanding about kernels" not to comprehend the kernel in its totality.


----------



## ralphbsz (Oct 24, 2017)

RimRunner said:


> I print you a list of different topics about kernel and ask you which parts have the most significant differences between Linux and FreeBSD: ...


Yes.  All of them.  The two kernels have nothing in common.  In terms of design and software engineering, they are wholly separate.

Given the GPL, I would assume that zero lines of code have been copied from Linux to the various *BSD kernels.  Given the Berkeley license, it would probably be possible to copy code from *BSD to Linux.  I vaguely remember early on in Linux land (somewhere around version 0.99 or 1.0), there was a BSD copyright notice on Linux.  Did that have something to do with the first Ethernet drivers, or were those copied from Crynwyr?  This is ancient history, now over 20 years ago.


----------



## tankist02 (Oct 26, 2017)

I'm curious - If Linux kernel is 20 million SLOC how many are in FreeBSD? I don't have a running FreeBSD installation and cannot do wc on /src myself.


----------



## azathoth (Oct 27, 2017)

gpatrick said:


> The Linux kernel is around 20 million SLOC. Good luck with finding someone who truly understands it in totality.
> 
> As a comparison, the first Linux kernel without including drivers was around 150,000 SLOC. The first release of Plan 9 from Bell Labs had a kernel with around 3600 SLOC and the drivers added another approx 9000 SLOC.
> 
> If I remember correctly, 4th Edition of Plan 9, for the entire system, was around 100,000 SLOC.




Will plan 9 run a web browser that will use gmail?


----------



## Oko (Oct 27, 2017)

tankist02 said:


> I'm curious - If Linux kernel is 20 million SLOC how many are in FreeBSD? I don't have a running FreeBSD installation and cannot do wc on /src myself.


Source files are not installed by default on FreeBSD. Entire FreeBSD has little less than 9 million lines of code. OpenBSD has less than 3 millions. I am talking about complete OS which in case of OpenBSD includes Xenocara and many, many useful user-land programs. The last time somebody went line by line through UNIX kernel (The John Lions' UNIX commentary) the whole kernel consisted of 6000 lines of code. Even a micro kernels like Minix3 contain more lines of code than that nowdays.


----------



## Oko (Oct 27, 2017)

azathoth said:


> Will plan 9 run a web browser that will use gmail?


It will only run its own Abaco web browser but unfortunately you will not be able to use gmail or see porn.


----------



## gpatrick (Oct 27, 2017)

azathoth said:


> Will plan 9 run a web browser that will use gmail?


9front is a Plan 9 fork and is constantly being updated with a focus on modernization.  Mothra is the browser used in 9front but it doesn't support Javascript.


> mothra is a trivial web browser written in 1995 by Tom Duff. It ignores Javascript, CSS and many HTML tags. It was dropped from Plan 9 after the 2nd Edition, but has been picked up and (somewhat) refined for 9front. mothra now uses webfs, and no longer supports non-HTTP protocols.



However, Cinap Lenrek, who is a 9front developer has a project called linuxemu3:


> linux binary emulator for plan9. use fgb's equis xserver from the plan9 contrib system to run x11 programs. for programs that use tls or are linked against a newer glibc with nptl a kernel patch is required.


I've never used it, but I've seen screenshots of the use of mplayer and xmms using linuxemu3.

There's a google thread where someone has used gmail via IMAP using upas/fs.  Again, I don't use gmail so I've never tried this, but seems doable.

I have hosted Inferno installed on my Windows machine and have used its Charon Web browser to read articles (read about OJ Simpson the day he was released from prison using Charon).  It also doesn't support Javascript or anything newer, but if you want to view porn like on Windows like Oko, static images will display in Charon.


----------



## RimRunner (Dec 25, 2017)

Okay, now if I start to inspect the issue and try to find kernel level differences between Linux and FreeBSD, may you have ideas, which parts of these kernels would be the most promising to find some interesting differences? (differences that are clear and meaningful and so on) Where to start looking for?

Different parts of kernel are for example process management, process scheduling, system calls, data structures (lists, queues, maps, binary trees...) , interrupts - their handlers and bottom halves, synchronization (of shared resource access), timers and time management, memory management, virtual filesystem, file system representation, the block I/O layer, page cache, modules, kernel objects


----------



## ShelLuser (Dec 26, 2017)

Why not set up a virtual machine, install FreeBSD, install the kernel source code and simpy start looking?


----------



## ralphbsz (Dec 26, 2017)

Differences?  It would be easier to find commonalities.  They both solve the same problem, but in entirely different fashions.  For a beginner it would even be difficult to find sections of code in both that actually solve the same problem.  For example: Find the place in the code where failed SCSI commands and unsolicited unit attentions are handled, and think through how it relates to the HBA device drivers below and the block (disk) driver above.  Very tricky territory.

Here would be one suggestion: Don't actually start with the code.  Instead, get a copy of the "Daemon Book" a.k.a. McKusick et al., Design and Implementation of the (Free-) BSD Operating System, try to get the newest edition so it matches your source as much as possible.  Read that thing cover to cover, multiple times, until you understand how the pieces fit together.  Then start digging into the source code, line by line.


----------



## azathoth (Dec 29, 2017)

Oko said:


> It will only run its own Abaco web browser but unfortunately you will not be able to use gmail or see porn.


well crap might as well not even have a computer then


----------



## poorandunlucky (Jan 5, 2018)

The FreeBSD kernel is modular, the Linux kernel is monolithic; the FreeBSD kernel was written by a lot of people, the Linux kernel was written by Linux Torvalds; ...

That's all I can help you with...


----------

