Added locking application in RAM.
authorMartin Prudek <prudemar@fel.cvut.cz>
Fri, 8 May 2015 16:44:17 +0000 (18:44 +0200)
committerMartin Prudek <prudemar@fel.cvut.cz>
Fri, 8 May 2015 16:44:17 +0000 (18:44 +0200)
pmsm-control/test_sw/misc.c

index 170bd54..906e29c 100644 (file)
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <stdio.h>     /*printf*/
 #include <pthread.h>
+#include <sys/mman.h>  /*mlockall*/
 
 #include "misc.h"
 
@@ -35,6 +36,11 @@ void setup_environment(){
        /*struktura pro signal handler*/
        struct sigaction sighnd;
 
+       if (mlockall(MCL_FUTURE | MCL_CURRENT) < 0) {
+           fprintf(stderr, "mlockall failed - cannot lock application in memory\n");
+           exit(1);
+        }
+
        atexit(appl_stop);
 
        /*nastaveni signalu pro vypnuti pomoci Ctrl+C*/