diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-10-31 13:37:59 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-11-02 08:46:47 +0100 |
commit | d271c3bb78f86dd9417a964b019b8e38911064fa (patch) | |
tree | 3c36b87c580464cc7f1e5aec89e1137a68759da3 /cpukit/score/src/iterateoverthreads.c | |
parent | posix: Fix timer interval (diff) | |
download | rtems-d271c3bb78f86dd9417a964b019b8e38911064fa.tar.bz2 |
rtems: Add rtems_task_iterate()
Update #2423.
Diffstat (limited to 'cpukit/score/src/iterateoverthreads.c')
-rw-r--r-- | cpukit/score/src/iterateoverthreads.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/cpukit/score/src/iterateoverthreads.c b/cpukit/score/src/iterateoverthreads.c index 8933352298..e829fc9edb 100644 --- a/cpukit/score/src/iterateoverthreads.c +++ b/cpukit/score/src/iterateoverthreads.c @@ -18,37 +18,28 @@ #include "config.h" #endif -#include <rtems/score/thread.h> -#include <rtems/score/objectimpl.h> +#include <rtems/score/threadimpl.h> -void rtems_iterate_over_all_threads(rtems_per_thread_routine routine) -{ - uint32_t i; - uint32_t api_index; - Thread_Control *the_thread; - Objects_Information *information; - - if ( !routine ) - return; +typedef struct { + rtems_per_thread_routine routine; +} routine_arg; - for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) { - #if !defined(RTEMS_POSIX_API) || defined(RTEMS_DEBUG) - if ( !_Objects_Information_table[ api_index ] ) - continue; - #endif - - information = _Objects_Information_table[ api_index ][ 1 ]; - if ( !information ) - continue; +static bool routine_adaptor( rtems_tcb *tcb, void *arg ) +{ + routine_arg *ra; - for ( i=1 ; i <= information->maximum ; i++ ) { - the_thread = (Thread_Control *)information->local_table[ i ]; + ra = arg; + ( *ra->routine )( tcb ); + return false; +} - if ( !the_thread ) - continue; +void rtems_iterate_over_all_threads( rtems_per_thread_routine routine ) +{ + routine_arg arg = { + .routine = routine + }; - (*routine)(the_thread); - } + if ( routine != NULL ) { + _Thread_Iterate( routine_adaptor, &arg ); } - } |