How does FreeBSD accomplish such minimalism?

When I boot into a default FreeBSD installation, I only get very few processes. It's very nice and refreshing. In Linux, the default install has a million processes.

How does FreeBSD accomplish this? Are all basic tasks packed into one process? Or is Linux doing a lot of things by default that FreeBSD doesn't?
 
No, but some Linux stuff is there by default because of design. I guess I'm asking about that more. BSD can run without all the 'kthread' and 'rcu_gp' and 'kworker' and 'ksoftirqd' and so on processes? Are they all functionally present in BSD and incorporated into one?
 
If I understand it correctly, your question is if FreeBSD is combining kernel processes rather than splitting them. Most Linux distress employ systems, which centralizes control, but may be inefficient in the process department. On the other hand, Linux may just be spawning processes because you might want to use something, someday or may be scared of the shell.

My 2 cents: Given that they both do the same thing and have similar origins, I would expect more overlap. However, my understanding is that FreeBSD is spare because it forgoes a lot of the Linux cruft in its base and moves it to the ports collection as it is not needed for a functional machine. In other words, the later is probably the case. I am sure wiser people than I will weigh in.
 
"The Design And Implementation Of The FreeBSD Operating System, 2nd edition"


But you may want to start here: https://download.freebsd.org/doc/en/books/design-44bsd/design-44bsd_en.pdf

In case you didn't know, FreeBSD is a direct descendant of the original UNIX and 4.4BSD code, some of the commits in the source tree are more than 40 years old. The Linux kernel was written from scratch by Linus to be a UNIX-workalike, but has diverged quite a lot since its inception.

FreeBSD's family tree and origins:
 
In Linux,

Which distro?

A few minutes ago, I wrote about DVD package set modernisation for 14.1.

After 14.1-RELEASE is announced (probably a few hours from now), you should be able to:

— write FreeBSD-14.1-RELEASE-amd64-dvd1.iso to a USB flash drive
— install the base OS (FreeBSD)
— continue with the same flash drive, install X.Org, KDE, SDDM, Firefox, documentation, and a few other packages from the list below
  • devel/git@lite
  • graphics/drm-kmod
  • graphics/drm-510-kmod
  • graphics/drm-515-kmod
  • misc/freebsd-doc-all
  • net/mpd5
  • net/rsync
  • ports-mgmt/pkg
  • shells/bash
  • shells/zsh
  • security/sudo
  • sysutils/screen
  • sysutils/seatd
  • sysutils/tmux
  • www/firefox
  • www/links
  • x11/gnome
  • x11/kde5
  • x11/sddm
  • x11/xorg
  • x11-wm/sway
— follow the package messages, then restart the OS.

How many processes run?
 
htop views of processes for Firefox on FreeBSD 15.0-CURRENT (the screen to the left) and Sparky Linux (to the right).

My Firefox on FreeBSD is far more busy (many tabs, heavily extended) than the first run of Firefox on Sparky (two tabs, no extension).

Someone once explained why so many more processes are detected with Firefox on Linux. Maybe in /r/firefox

1717452060885.png
 

Attachments

  • 1717452320424.png
    1717452320424.png
    158.3 KB · Views: 87
When I boot into a default FreeBSD installation, I only get very few processes. It's very nice and refreshing. In Linux, the default install has a million processes.

How does FreeBSD accomplish this? Are all basic tasks packed into one process? Or is Linux doing a lot of things by default that FreeBSD doesn't?

There is no "default install" for Linux because there are tons of distros with tons of different defaults. Some are significantly *more* minimalist than FreeBSD, some significantly less.

It's mostly just a question of defaults. FreeBSD comes with very little out of the box, some Linux distros with more. Both are fine approaches.

My Arch Linux (systemd) system has roughly the same number of processes as a default FreeBSD installation. Void Linux has more because it uses runit, which has two or three processes for every service (runsv to monitor the process, and the process itself, and then optionally also vlogger for logging). That's a fine approach: you're not going to run out of processes.
 
There is no "default install" for Linux because there are tons of distros with tons of different defaults. Some are significantly *more* minimalist than FreeBSD, some significantly less.

It's mostly just a question of defaults. FreeBSD comes with very little out of the box, some Linux distros with more. Both are fine approaches.

My Arch Linux (systemd) system has roughly the same number of processes as a default FreeBSD installation. Void Linux has more because it uses runit, which has two or three processes for every service (runsv to monitor the process, and the process itself, and then optionally also vlogger for logging). That's a fine approach: you're not going to run out of processes.
Really? Your Arch default kernel starts off with the same amount of processes as a default FreeBSD installation? I have a slimmed down Linux kernel that spawns just all sorts of processes on boot, I don't think it has to do with any packages installed, they all look kernel-related or low-level driver related.

So, it looks like FreeBSD just rolls up all its kernel functions into the kernel (init?) versus spawning separate processes? But there's no init process on FreeBSD. Where are all the kernel-related processes, kernel services etc?
 
Really? Your Arch default kernel starts off with the same amount of processes as a default FreeBSD installation? I have a slimmed down Linux kernel that spawns just all sorts of processes on boot, I don't think it has to do with any packages installed, they all look kernel-related or low-level driver related.

So, it looks like FreeBSD just rolls up all its kernel functions into the kernel (init?) versus spawning separate processes? But there's no init process on FreeBSD. Where are all the kernel-related processes, kernel services etc?

"The kernel" doesn't really start of with any processes. Unless you mean kernel threads (displayed in [square brackets])? That's a rather different thing than a process.

I don't know the exact design considerations on any of this, and it's entirely possible the differences are much smaller than it might appear and just displays more details on Linux than FreeBSD.

I certainly wouldn't mistake a different design for "minimalism"; runit is fairly minimal but starts many processes.
 
Freebsd is pretty nice in this respect, but as soon as you put one of the mainstream desktop environments on it (gnome, kde, etc) you will see lots of additional processes being started. Conversely if you do a minimal install on linux (no desktop) and then install a window manager like fvwm, blackbox or windowmaker (as opposed to a DE) you will find that the number of processes is similar to what you see on freebsd. Similarly you can bloat out freebsd's process table by installing a desktop environment on it. A lot of the processes you see running are there to support the DE. If you like having a lot of fancy desktop functionality, those additional processe are what is needed to implement what you see on the screen. On modern hardware it's just a personal choice, if you have 8GB of RAM and a multi-core cpu the whole DE still only uses a small fraction of the machine's hardware resources.

And don't forget that when you list processes with 'ps', the names enclosed in square brackets are just kernel threads, not processes; the list isn't as long as it looks.
 
So I don't think you're comparing apples to apples here, you're comparing BSD as an operating system to Linux as an operating system but there's no standard Linux operating system.

You can run a linux kernel with only a single init process if you wish to do so.

You could also be confused with how linux presents its kernel threads, which are exposed in /proc.
 
You can run a linux kernel with only a single init process if you wish to do so.

You could also be confused with how linux presents its kernel threads, which are exposes in /proc.
Ok, thank you, I am talking about kernel threads. I can see Linux kernel threads both in /proc but also via a `top` command. I don't think I see any kernel threads in FreeBSD when I run `top`. How can I see FreeBSD kernel threads?
 
Ok, thank you, I am talking about kernel threads. I can see Linux kernel threads both in /proc but also via a `top` command. I don't think I see any kernel threads in FreeBSD when I run `top`. How can I see FreeBSD kernel threads?
You can use `ps -x`. This will allow `ps` to view processes with no console.

The first 17 processes or so will have brackets around them because ps can't read their cmdline, I think these are kernel threads.
 
When I boot into a default FreeBSD installation, I only get very few processes. It's very nice and refreshing. In Linux, the default install has a million processes.
And you seem to think that having few processes is a good thing. Why?

I would assume that the people designing Linux know how to optimize the system for its intended workload and hardware. I'm quite sure they are very good at that, and the massive success of Linux indicates that they got it right (90% market share among servers, 100% of supercomputers, the only open source OS to have a meaningful presence on the desktop ...). If having many processes/threads is a good solution, what's the problem?

(Apart from the obvious question that threads are not the same as processes, even if they sometimes look similar ...)
 
Focusing on kernel threads/ithreads, Linux kernel could show kernel threads for devices which FreeBSD does not (yet) support but Linux kernel does. These would include virtual devices and shared interrupts (for ithreads).
 
You can use `ps -x`. This will allow `ps` to view processes with no console.

The first 17 processes or so will have brackets around them because ps can't read their cmdline, I think these are kernel threads.
Oh, yes, thank you. I ran `ps aux`, and that shows a few kernel threads. But very, very few! I guess `top` on BSD doesn't show kernel threads by default. So my question still stands - how does BSD accomplish this?
 
And you seem to think that having few processes is a good thing. Why?

I would assume that the people designing Linux know how to optimize the system for its intended workload and hardware. I'm quite sure they are very good at that, and the massive success of Linux indicates that they got it right (90% market share among servers, 100% of supercomputers, the only open source OS to have a meaningful presence on the desktop ...). If having many processes/threads is a good solution, what's the problem?

(Apart from the obvious question that threads are not the same as processes, even if they sometimes look similar ...)
That is very good questions! You, of course, assume Linux has got it right. Well, I couldn't get a Wi-Fi hotspot working flawlessly on Linux. So maybe FreeBSD has the best/most secure network stack? Wide adoption of Linux is not telling of anything, really. It's like that statistical correlation example when high icecream use in NYC coincided with a spike in drownings, but there's no causation between the two.

There could be security issues with many kernel threads, depending on what they are and how they are implemented. If things make sense, they make sense. When a barebones FreeBSD install has very few kernel threads and processes, it is more logical, less attack surface I guess even maybe?
 
Back
Top