# Realtime or Low Latency Custom Kernel for Audio related work?



## revivaloflostart (Oct 5, 2018)

Hi guys,
I'm pretty new to FreeBSD, but I was just wondering if it's possible to set up some kind of realtime or low latency custom kernel for Freebsd? or if such custom kernel exist?  

I originally came from archlinux and typically use its linux-rt kernel, which typically grants a latency of about 6-10 ms as opposed to the regular linux kernel which sits at about 15-20 ms.

Any advice would be greatly appreciate; thanks in advance.


----------



## shepper (Oct 6, 2018)

The default kernel I believe is realtime.  Some latency is introduced by sound servers.  I do not recall seeing any mention that FreeBSD includes a sound server by default.

Depending on your needs, you may also want to look at NetBSD 8.0 which introduced an in-kernel mixer
NetBSD audio_system(9)

An install of OpenBSD has sndio enabled by default but it can be disabled.


----------



## rigoletto@ (Oct 7, 2018)

NO general purpose kernel is hard real-time, including Linux with rt patches which still is soft real-time, you would need to modify almost the entire kernel to make it fully work in preemptive mode. The closer you will get of general purpose hard RTOS probably is RTLinux, but it is not an actual general purpose OS as you can read in their literature.

That said, recording of some talks with people who has deep knowledge of the FreeBSD kernel code it has enough preemption to be considered a soft RTOS (but don't take my memory as the most reliable thing).



revivaloflostart said:


> I originally came from archlinux and typically use its linux-rt kernel, which typically grants a latency of about 6-10 ms as opposed to the regular linux kernel which sits at about 15-20 ms.



Assuming you are concerned with audio, IIRC sound(4) has some built in latency tweaks.

This probably should be what you are looking for:



> hw.snd.latency
> 
> Configure the buffering latency.  Only affects applications that
> do not explicitly request blocksize / fragments.  This tunable
> ...


----------

