# Kernel Preemption on FreeBSD



## nactusberrilli (Aug 24, 2018)

Does the FreeBSD kernel come with a preemption feature enabled by default?


----------



## drhowarddrfine (Aug 24, 2018)

No. From "The Design and Implementation of the FreeBSD Operating System"


> The FreeBSD kernel is never preempted to run another user process while executing in the top half of the kernel although it will explicitly give up the processor if it must wait for an event or for a shared resource.



You might have better luck asking these types of questions on the mailing lists.


----------



## leebrown66 (Aug 24, 2018)

Yes, this is a pre-emptive kernel, not a co-operative one.

If you are interested in learning more, I would highly recommend reading "The Design and Implementation of the FreeBSD Operating System"
Oh, my bad, I was thinking user space.


----------



## nactusberrilli (Aug 24, 2018)

drhowarddrfine said:


> No. The FreeBSD kernel is never preempted to run another user process while executing in the top half of the kernel although it will explicitly give up the processor if it must wait for an event or for a shared resource.
> 
> You might have better luck asking these types of questions on the mailing lists.



I have noticed that NetBSD has added preemption and real-time scheduling extensions since version 5 (back in 2009). Does this mean that NetBSD is a better choice for embedded systems (specifically for real-time applications)?


----------



## drhowarddrfine (Aug 24, 2018)

I didn't mean to imply I was an expert on this. I only recall reading that paragraph from "The Design and Implementation of the FreeBSD Operating System", looked it up, but was called away before I could cite my source which I will now do. Sorry.

Now, that's a user process and I don't know anything about embedded FreeBSD. Some years back, I could give an expert answer but no more.


----------



## t1066 (Aug 25, 2018)

Run `grep -R -i -I preemption /usr/src/sys`, I get 144 lines including

```
/usr/src/sys/arm64/conf/GENERIC:options         PREEMPTION              # Enable kernel thread preemption
```


----------

