]> rtime.felk.cvut.cz Git - ert_linux.git/blobdiff - ert_linux/ert_linux_main.tlc
Suppress warning about thread return value.
[ert_linux.git] / ert_linux / ert_linux_main.tlc
index e9c4545db223f3cd6918bd670d32d8462bfa654e..ea4bf4b32b28dd0dceaef199a883060417802a10 100644 (file)
   #include <semaphore.h>                 /* Semaphores library header file */
   #include <time.h>
   #include <stdlib.h>
+  #include <stdbool.h>
   #include <unistd.h>
+  #include <sys/mman.h>                  /* For mlockall() */
   #include "%<modelName>.h"              /* Model's header file */
   #include "rtwtypes.h"                  /* MathWorks types */
   %if extMode == 1
     #include "ext_work.h"                  /* External mode header file */
   %endif
 
+  #ifndef TRUE
+  #define TRUE true
+  #define FALSE false
+  #endif
+
   /*==================*
    * Required defines *
    *==================*/
    */
   int simulationFinished = 0;
 
+  %if extMode == 1
+    /* Indication that the base rate thread has started */
+    sem_t ext_mode_ready;
+  %endif
 %endfunction
 
 %function printfunc() Output
        %<modelName>_step%<i>();
        sem_wait(&sub_rate[%<i>].sem);    /* sem_val = 0 */
       }
+      return NULL;
     }
   %endforeach
 %endfunction
 
     %if extMode == 1
       %<SLibGenERTExtModeInit()>
+      CHECKE(sem_post(&ext_mode_ready));
     %endif
 
     clock_gettime(CLOCK_MONOTONIC, &next);
 
     %if extMode == 1
       /* External mode */
-      rtERTExtModeParseArgs(argc, argv);
+      /* rtERTExtModeParseArgs(argc, argv); */
+      rtExtModeParseArgs(argc, argv, NULL);
+      CHECKE(sem_init(&ext_mode_ready, 0, 0));
     %else
       (void)(argc);
       (void *)(argv);
     %endif
 
+    CHECKE(mlockall(MCL_FUTURE));
+
     /* Initialize model */
     %<modelName>_initialize();
     simulationFinished = 0;
 
     %if extMode == 1
       /* External mode */
+      CHECKE(sem_wait(&ext_mode_ready));
       while(rtmGetErrorStatus(%<modelName>_M) == NULL && !rtmGetStopRequested(%<modelName>_M)) {
         rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL), NUMST, (boolean_T *)&rtmGetStopRequested(RT_MDL));
        usleep(%<FEVAL("uint32", fundamentalStepSize * 1000000)>);