Linux has a single priority level (0) for SCHED_OTHER and [1,99] for SCHED_FIFO and SCHED_RR. FreeBSD supports [0,31] for all scheduling policies. Programs are supposed to query the valid range using sched_get_priority_(min|max), but of course some programs assume the Linux values are valid.
This patch adds a sysctl compat.linux.map_sched_prio. When enabled sched_get_priority_(min|max) will return the Linux values and sched_setscheduler and sched_(get|set)param translate between FreeBSD and Linux values.
Because there are more Linux levels than FreeBSD levels, multiple Linux levels map to a single FreeBSD level, which means pre-emption might not happen as it does on Linux. So the sysctl allows to disable this behaviour. It is enabled by default because I think it is unlikely that anyone runs real-time software under Linux emulation on FreeBSD that critically relies on correct pre-emption.
This patch fixes FMOD, a commercial sound library used by several games. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240043