Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does OpenBSD support parallel Kernel access

I tried to figure out if multiple processes or threads can execute concurrent syscalls, without one of them sleeping. That's to say: Does OpenBSD use something like a Big Kernel Lock.

One would expect, that parallel Kernel access is possible. I tried to look into the syscall interface (code-reading and kernel debugging) and didn't find anything that would strike me as BKL. However, when I look into the fork syscall implementation, it appears to me, that some global data is accessed without locking (e.g. nprocesses). I was wondering, if the scheduler (?), somehow, prevents parallel syscalls, or if I am overlooking something.

So: Does OpenBSD support parallel Kernel access and how about other BSDs?

like image 507
prometheus Avatar asked Aug 24 '26 07:08

prometheus


1 Answers

Indeed, OpenBSD has a rather archaic model, which uses priority levels, distinct for each subsystem. See spl(9).

The mechanism originally allowed some preemption, but only from higher priority interrupts. On modern implementations of course the priority levels are implemented by mutexes.

The scheduler uses splsched.

So, there's several locks, and syscalls take place in parallel (across different CPUs) but serialize due to these locks at certain points, depending on the subsystem boundaries they're crossing. In other words, never two threads will be running code from the same subsystem concurrently; of course this could change at any moment if a lock is split or replaced.

Other systems:

  • This is inherited from NetBSD, so it's about the same.
  • FreeBSD has transitioned to a more granular approach, with some parts being lockless, much like Linux.
  • DragonflyBSD improves upon FreeBSD by providing serialization tokens for synchronization, and an inherently lockless approach to key mechanisms, like memory allocation (both userspace and kernel).
like image 143
Ismael Luceno Avatar answered Aug 27 '26 00:08

Ismael Luceno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!