diff --git a/src/linux/main.c b/src/linux/main.c index c8cb3dfd..f9ea3f6d 100644 --- a/src/linux/main.c +++ b/src/linux/main.c @@ -4,10 +4,11 @@ // // This file may be distributed under the terms of the GNU GPLv3 license. -#include // sched_setscheduler +#include // sched_setscheduler sched_get_priority_max #include // fprintf #include // memset #include // getopt +#include // mlockall MCL_CURRENT MCL_FUTURE #include "board/misc.h" // console_sendf #include "command.h" // DECL_CONSTANT #include "internal.h" // console_setup @@ -25,12 +26,18 @@ realtime_setup(void) { struct sched_param sp; memset(&sp, 0, sizeof(sp)); - sp.sched_priority = 1; + sp.sched_priority = sched_get_priority_max(SCHED_FIFO) / 2; int ret = sched_setscheduler(0, SCHED_FIFO, &sp); if (ret < 0) { report_errno("sched_setscheduler", ret); return -1; } + // Lock ourselves into memory + ret = mlockall(MCL_CURRENT | MCL_FUTURE); + if (ret) { + report_errno("mlockall", ret); + return -1; + } return 0; }