]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Move model initialization to the working thread
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 13 Sep 2013 14:50:15 +0000 (16:50 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 13 Sep 2013 14:50:15 +0000 (16:50 +0200)
When initialization is done, signal it to the control task.

With this change, the Start method of all blocks can expect that FreeRTOS
is fully initialized and that the stack size for initialization is the
same as for steps (which can be configured in in Code generation
configuration).

Fixes #371 @30min.

rpp/rpp/rpp_srmain.tlc

index d34c452c0d9cb8b8ddba034ffde462d981d21855..a22a85ed1c26808ab454a92b5b3bccc356cd4f43 100644 (file)
@@ -72,6 +72,7 @@
     static boolean_t WORKING = FALSE;
     static boolean_t SHUTDOWN = FALSE;
     static xSemaphoreHandle step_signal = NULL;
+    static xSemaphoreHandle initialized_signal = NULL;
     static uint32_t steps_control = 0;
     static uint32_t steps_working = 0;
 
@@ -89,6 +90,8 @@
     void control_task(void* p)
     {
 
+         xSemaphoreTake(initialized_signal, portMAX_DELAY);
+
         static const portTickType freq_ticks = STEP_SIZE_MILLIS / portTICK_RATE_MS;
         portTickType last_wake_time = xTaskGetTickCount();
 
      */
     void working_task(void* p)
     {
+        /* Initialize model */
+        %<LibCallModelInitialize()>\
+
+        xSemaphoreGive(initialized_signal);
+
         while(!SHUTDOWN) {
 
             /* Lock semaphore */
             );
         %endif
 
-        /* Initialize model */
-        %<LibCallModelInitialize()>\
-
         /* Create and lock semaphore */
         vSemaphoreCreateBinary(step_signal);
         xSemaphoreTake(step_signal, 0);
+        vSemaphoreCreateBinary(initialized_signal);
+        xSemaphoreTake(initialized_signal, 0);
 
         /* Create tasks to step model and model task */
         if(xTaskCreate(control_task, (const signed char*)"control_task",