Page MenuHomeFreeBSD

linuxulator: Map scheduler priorities to Linux priorities
ClosedPublic

Authored by tijl on Feb 22 2020, 2:37 PM.
Referenced Files
Unknown Object (File)
Fri, Jun 21, 9:54 PM
Unknown Object (File)
Wed, Jun 5, 10:45 PM
Unknown Object (File)
May 11 2024, 8:25 PM
Unknown Object (File)
May 9 2024, 5:41 AM
Unknown Object (File)
May 8 2024, 9:47 PM
Unknown Object (File)
Apr 13 2024, 10:44 PM
Unknown Object (File)
Mar 31 2024, 7:37 AM
Unknown Object (File)
Mar 11 2024, 12:10 AM

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