summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/iterateoverthreads.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-08-14 20:04:18 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-08-14 20:04:18 +0000
commit17c6686753e583c8a8c37474beea6e67d9b5a43f (patch)
tree703c7f266181ac32c5a6fb370d5eaec4186d0056 /cpukit/score/src/iterateoverthreads.c
parent2003-08-14 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-17c6686753e583c8a8c37474beea6e67d9b5a43f.tar.bz2
2003-08-14 Joel Sherrill <joel@OARcorp.com>
PR 408/filesystem * score/Makefile.am, score/include/rtems/score/thread.h: Added sync() service. As part of adding this service, the new RTEMS service rtems_iterate_over_all_threads() was also added. This new service makes it easier to iterate over all the tasks/threads in a system and perform an action on them. * score/src/iterateoverthreads.c: New file. * ChangeLog: Fixed screwup.
Diffstat (limited to 'cpukit/score/src/iterateoverthreads.c')
-rw-r--r--cpukit/score/src/iterateoverthreads.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/cpukit/score/src/iterateoverthreads.c b/cpukit/score/src/iterateoverthreads.c
new file mode 100644
index 0000000000..7e698e67a1
--- /dev/null
+++ b/cpukit/score/src/iterateoverthreads.c
@@ -0,0 +1,46 @@
+/*
+ * rtems_iterate_over_all_threads
+ *
+ * This function operates by as follows:
+ * for all threads
+ * invoke specified function
+ *
+ * COPYRIGHT (c) 1989-2003.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems/system.h>
+#include <rtems/score/thread.h>
+
+void rtems_iterate_over_all_threads(rtems_per_thread_routine routine)
+{
+ unsigned32 i;
+ unsigned32 api_index;
+ Thread_Control *the_thread;
+ Objects_Information *information;
+
+ for ( api_index = 1 ;
+ api_index <= OBJECTS_APIS_LAST ;
+ api_index++ ) {
+ if ( !_Objects_Information_table[ api_index ] )
+ continue;
+ information = _Objects_Information_table[ api_index ][ 1 ];
+ if ( information ) {
+ for ( i=1 ; i <= information->maximum ; i++ ) {
+ the_thread = (Thread_Control *)information->local_table[ i ];
+
+ if ( !the_thread )
+ continue;
+
+ (*routine)(the_thread);
+ }
+ }
+ }
+
+}