Page MenuHomeFreeBSD

linuxulator: Map scheduler priorities to Linux priorities
ClosedPublic

Authored by tijl on Feb 22 2020, 2:37 PM.
Referenced Files
F112792422: D23790.diff
Sat, Mar 22, 8:01 PM
Unknown Object (File)
Tue, Mar 11, 3:05 AM
Unknown Object (File)
Feb 21 2025, 4:57 AM
Unknown Object (File)
Feb 20 2025, 1:54 AM
Unknown Object (File)
Feb 7 2025, 3:11 PM
Unknown Object (File)
Jan 30 2025, 4:36 AM
Unknown Object (File)
Jan 30 2025, 4:28 AM
Unknown Object (File)
Jan 17 2025, 3:49 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