mirror of
https://github.com/thelsing/knx.git
synced 2025-02-23 00:15:35 +01:00
Prevent swapping of process
This commit is contained in:
parent
15b318992d
commit
5f36196e78
@ -11,7 +11,10 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
volatile sig_atomic_t loopActive = 1;
|
volatile sig_atomic_t loopActive = 1;
|
||||||
void signalHandler(int sig)
|
void signalHandler(int sig)
|
||||||
@ -109,6 +112,13 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
printf("main() start.\n");
|
printf("main() start.\n");
|
||||||
|
|
||||||
|
// Prevent swapping of this process
|
||||||
|
struct sched_param sp;
|
||||||
|
memset(&sp, 0, sizeof(sp));
|
||||||
|
sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||||
|
sched_setscheduler(0, SCHED_FIFO, &sp);
|
||||||
|
mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||||
|
|
||||||
// Register signals
|
// Register signals
|
||||||
signal(SIGINT, signalHandler);
|
signal(SIGINT, signalHandler);
|
||||||
signal(SIGTERM, signalHandler);
|
signal(SIGTERM, signalHandler);
|
||||||
|
Loading…
Reference in New Issue
Block a user