Page MenuHomeFreeBSD

linuxulator: Map scheduler priorities to Linux priorities
ClosedPublic

Authored by tijl on Feb 22 2020, 2:37 PM.
Referenced Files
F149380460: D23790.id69027.diff
Tue, Mar 24, 2:12 AM
Unknown Object (File)
Mon, Mar 23, 1:05 AM
Unknown Object (File)
Sat, Mar 21, 2:41 PM
Unknown Object (File)
Sat, Mar 21, 7:17 AM
Unknown Object (File)
Sat, Mar 21, 7:17 AM
Unknown Object (File)
Thu, Mar 19, 8:43 AM
Unknown Object (File)
Dec 28 2025, 4:14 PM
Unknown Object (File)
Nov 24 2025, 10:30 PM

Details

Summary

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

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable