summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/score/ChangeLog9
-rw-r--r--cpukit/score/Makefile.am2
-rw-r--r--cpukit/score/include/rtems/score/thread.h15
-rw-r--r--cpukit/score/src/iterateoverthreads.c46
4 files changed, 70 insertions, 2 deletions
diff --git a/cpukit/score/ChangeLog b/cpukit/score/ChangeLog
index 860b886692..8fb864cf74 100644
--- a/cpukit/score/ChangeLog
+++ b/cpukit/score/ChangeLog
@@ -1,6 +1,13 @@
2003-08-14 Joel Sherrill <joel@OARcorp.com>
- * ChangeLog: Add fileio to list of interactive tests.
+ 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.
2003-07-18 Till Straumann <strauman@slac.stanford.edu>
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 3a8e844f00..40efdf999c 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -142,7 +142,7 @@ THREAD_C_FILES = src/thread.c src/threadchangepriority.c src/threadclearstate.c
src/threadsetpriority.c src/threadsetstate.c src/threadsettransient.c \
src/threadstackallocate.c src/threadstackfree.c src/threadstart.c \
src/threadstartmultitasking.c src/threadsuspend.c src/threadtickletimeslice.c \
- src/threadyieldprocessor.c
+ src/threadyieldprocessor.c src/iterateoverthreads.c
THREADQ_C_FILES = src/threadq.c src/threadqdequeue.c src/threadqdequeuefifo.c \
src/threadqdequeuepriority.c src/threadqenqueue.c src/threadqenqueuefifo.c \
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 18d4774a5d..1005aa2eff 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -763,6 +763,21 @@ Thread _Thread_Idle_body(
);
#endif
+/*
+ * rtems_iterate_over_all_tasks
+ *
+ * DESCRIPTION:
+ *
+ * This routine iterates over all threads regardless of API and
+ * invokes the specified routine.
+ */
+
+typedef void (*rtems_per_thread_routine)( Thread_Control * );
+
+void rtems_iterate_over_all_threads(
+ rtems_per_thread_routine routine
+);
+
#ifndef __RTEMS_APPLICATION__
#include <rtems/score/thread.inl>
#endif
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);
+ }
+ }
+ }
+
+}