Commit 29886583 authored by yoogx's avatar yoogx
Browse files

* Activate thread affinity for RTEMS target

        For openaadl/ocarina#102
parent ee563f35
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* For more informations, please visit http://taste.tuxfamily.org/wiki * For more informations, please visit http://taste.tuxfamily.org/wiki
* *
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2019 ESA & ISAE. * Copyright (C) 2007-2009 Telecom ParisTech, 2010-2020 ESA & ISAE.
*/ */
#if defined (__linux__) || defined (RTEMS412) #if defined (__linux__) || defined (RTEMS412)
...@@ -173,7 +173,7 @@ void __po_hi_wait_for_tasks () ...@@ -173,7 +173,7 @@ void __po_hi_wait_for_tasks ()
* __po_hi_create_vcd_file when the program terminates * __po_hi_create_vcd_file when the program terminates
* normally */ * normally */
atexit(__po_hi_create_vcd_file); atexit(__po_hi_create_vcd_file);
#endif #endif
int i; int i;
...@@ -181,17 +181,17 @@ void __po_hi_wait_for_tasks () ...@@ -181,17 +181,17 @@ void __po_hi_wait_for_tasks ()
{ {
pthread_join( tasks[i].tid , NULL ); pthread_join( tasks[i].tid , NULL );
} }
#if defined(__PO_HI_USE_VCD) && defined(__unix__) #if defined(__PO_HI_USE_VCD) && defined(__unix__)
/* initialize the index of the vcd trace array /* initialize the index of the vcd trace array
* and its maximum size*/ * and its maximum size*/
__po_hi_vcd_trace_array_index = 0; __po_hi_vcd_trace_array_index = 0;
__po_hi_vcd_trace_max_nb_events = 0; __po_hi_vcd_trace_max_nb_events = 0;
if (__po_hi_vcd_trace_array_index == __po_hi_vcd_trace_max_nb_events) if (__po_hi_vcd_trace_array_index == __po_hi_vcd_trace_max_nb_events)
__po_hi_get_larger_array_for_vcd_trace (); __po_hi_get_larger_array_for_vcd_trace ();
#endif #endif
#elif defined (__PO_HI_RTEMS_CLASSIC_API) #elif defined (__PO_HI_RTEMS_CLASSIC_API)
rtems_task_suspend(RTEMS_SELF); rtems_task_suspend(RTEMS_SELF);
...@@ -307,16 +307,16 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task) ...@@ -307,16 +307,16 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
#if defined(__PO_HI_USE_VCD) && defined(__unix__) #if defined(__PO_HI_USE_VCD) && defined(__unix__)
uint64_t current_timestamp = __po_hi_compute_timestamp(); uint64_t current_timestamp = __po_hi_compute_timestamp();
#endif #endif
int ret; int ret;
#if defined(__PO_HI_USE_VCD) && defined(__unix__) #if defined(__PO_HI_USE_VCD) && defined(__unix__)
if ((tasks[task].task_category) == TASK_PERIODIC || (tasks[task].task_category) == TASK_SPORADIC) 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); __po_hi_save_event_in_vcd_trace(current_timestamp, __po_hi_task_wait_dispatch, task, invalid_local_port_t, -1);
} }
#endif #endif
__po_hi_task_delay_until (&(tasks[task].timer), task); __po_hi_task_delay_until (&(tasks[task].timer), task);
if ( (ret = __po_hi_compute_next_period (task)) != 1) if ( (ret = __po_hi_compute_next_period (task)) != 1)
...@@ -324,14 +324,14 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task) ...@@ -324,14 +324,14 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
return (__PO_HI_ERROR_CLOCK); return (__PO_HI_ERROR_CLOCK);
} }
#if defined(__PO_HI_USE_VCD) && defined(__unix__) #if defined(__PO_HI_USE_VCD) && defined(__unix__)
current_timestamp = __po_hi_compute_timestamp(); current_timestamp = __po_hi_compute_timestamp();
if ((tasks[task].task_category) == TASK_PERIODIC) 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); __po_hi_save_event_in_vcd_trace (current_timestamp, __po_hi_task_dispatched, task, invalid_local_port_t, -1);
} }
#endif #endif
return (__PO_HI_SUCCESS); return (__PO_HI_SUCCESS);
#elif defined (_WIN32) #elif defined (_WIN32)
...@@ -417,7 +417,7 @@ int __po_hi_number_of_cpus (void) ...@@ -417,7 +417,7 @@ int __po_hi_number_of_cpus (void)
{ {
int cores = 1; int cores = 1;
#if defined (__linux__) || defined (__APPLE__) #if defined (__linux__) || defined (__APPLE__) || (defined (RTEMS_POSIX) && defined (RTEMS412))
cores = (int) sysconf (_SC_NPROCESSORS_ONLN); cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
#endif #endif
...@@ -453,10 +453,9 @@ pthread_t __po_hi_posix_create_thread (__po_hi_priority_t priority, ...@@ -453,10 +453,9 @@ pthread_t __po_hi_posix_create_thread (__po_hi_priority_t priority,
return ((pthread_t)__PO_HI_ERROR_PTHREAD_ATTR); return ((pthread_t)__PO_HI_ERROR_PTHREAD_ATTR);
} }
#if (defined (POSIX) && defined (__linux__)) #if (defined (POSIX) && defined (__linux__)) || (defined (RTEMS_POSIX) && defined (RTEMS412))
/* The following is disabled pending further investigation on affinity support in 4.11.99 */ /* RTEMS SMP support has been confirmed to work on TASTE */
/*|| (defined (RTEMS_POSIX) && defined (RTEMS412))) */
#ifndef __COMPCERT__ #ifndef __COMPCERT__
/* Thread affinity */ /* Thread affinity */
......
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