Commit 658cdfc6 authored by bouazizrahma's avatar bouazizrahma

fix the generation of the vcd trace using mutex

parent b1fefb19
......@@ -167,13 +167,31 @@ void __po_hi_wait_for_tasks ()
#if defined (RTEMS_POSIX) || defined (POSIX) || defined (XENO_POSIX)
#if defined(__PO_HI_USE_VCD) && defined(__unix__)
/* the atexit function allows the call of the function
* __po_hi_create_vcd_file when the program terminates
* normally */
atexit(__po_hi_create_vcd_file);
#endif
int i;
for (i = 0; i < __PO_HI_NB_TASKS; i++)
{
pthread_join( tasks[i].tid , NULL );
}
#if defined(__PO_HI_USE_VCD) && defined(__unix__)
/* initialize the index of the vcd trace array
* and its maximum size*/
__po_hi_vcd_trace_array_index = 0;
__po_hi_vcd_trace_max_nb_events = 0;
if (__po_hi_vcd_trace_array_index == __po_hi_vcd_trace_max_nb_events)
__po_hi_get_larger_array_for_vcd_trace ();
#endif
#elif defined (__PO_HI_RTEMS_CLASSIC_API)
rtems_task_suspend(RTEMS_SELF);
......@@ -274,7 +292,6 @@ int __po_hi_compute_next_period (__po_hi_task_id task)
#endif
}
int __po_hi_wait_for_next_period (__po_hi_task_id task)
{
......@@ -286,8 +303,20 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
#endif
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
#if defined(__PO_HI_USE_VCD) && defined(__unix__)
uint64_t current_timestamp = __po_hi_compute_timestamp();
#endif
int ret;
__PO_HI_INSTRUMENTATION_VCD_WRITE("0t%d\n", task);
#if defined(__PO_HI_USE_VCD) && defined(__unix__)
if ((tasks[task].task_category) == TASK_PERIODIC || (tasks[task].task_category) == TASK_SPORADIC)
{
__po_hi_save_event_in_vcd_trace(current_timestamp, __po_hi_task_wait_dispatch, task, invalid_local_port_t, -1);
}
#endif
__po_hi_task_delay_until (&(tasks[task].timer), task);
if ( (ret = __po_hi_compute_next_period (task)) != 1)
......@@ -295,8 +324,14 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
return (__PO_HI_ERROR_CLOCK);
}
__PO_HI_INSTRUMENTATION_VCD_WRITE("1t%d\n", task);
#if defined(__PO_HI_USE_VCD) && defined(__unix__)
current_timestamp = __po_hi_compute_timestamp();
if ((tasks[task].task_category) == TASK_PERIODIC)
{
__po_hi_save_event_in_vcd_trace (current_timestamp, __po_hi_task_dispatched, task, invalid_local_port_t, -1);
}
#endif
return (__PO_HI_SUCCESS);
#elif defined (_WIN32)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment