sys_posix: support SCHED_FIFO and mlockall on more OSs

Real-time scheduling and memory locking is available on posix compliant
OSs. This patch centralizes this functionality and brings support to
FreeBSD, NetBSD, and Solaris.

[ML: updated coding style]
This commit is contained in:
Stefan R. Filipek
2019-04-19 14:41:14 -04:00
committed by Miroslav Lichvar
parent a78031ce0d
commit c5c80ef400
7 changed files with 195 additions and 105 deletions

13
sys.c
View File

@@ -35,10 +35,13 @@
#if defined(LINUX)
#include "sys_linux.h"
#include "sys_posix.h"
#elif defined(SOLARIS)
#include "sys_solaris.h"
#include "sys_posix.h"
#elif defined(NETBSD) || defined(FREEBSD)
#include "sys_netbsd.h"
#include "sys_posix.h"
#elif defined(MACOSX)
#include "sys_macosx.h"
#endif
@@ -124,10 +127,10 @@ void SYS_EnableSystemCallFilter(int level)
void SYS_SetScheduler(int SchedPriority)
{
#if defined(LINUX) && defined(HAVE_PTHREAD_SETSCHEDPARAM)
SYS_Linux_SetScheduler(SchedPriority);
#elif defined(MACOSX)
#if defined(MACOSX)
SYS_MacOSX_SetScheduler(SchedPriority);
#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
SYS_Posix_SetScheduler(SchedPriority);
#else
LOG_FATAL("scheduler priority setting not supported");
#endif
@@ -137,8 +140,8 @@ void SYS_SetScheduler(int SchedPriority)
void SYS_LockMemory(void)
{
#if defined(LINUX) && defined(HAVE_MLOCKALL)
SYS_Linux_MemLockAll(1);
#if defined(HAVE_MLOCKALL)
SYS_Posix_MemLockAll();
#else
LOG_FATAL("memory locking not supported");
#endif