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/rtems | |
parent | posix: Fix timer interval (diff) | |
download | rtems-d271c3bb78f86dd9417a964b019b8e38911064fa.tar.bz2 |
rtems: Add rtems_task_iterate()
Update #2423.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r-- | cpukit/rtems/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/tasks.h | 32 | ||||
-rw-r--r-- | cpukit/rtems/src/taskiterate.c | 31 |
3 files changed, 64 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index 4be426620c..6ecff9e068 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -93,6 +93,7 @@ librtems_a_SOURCES += src/taskgetscheduler.c librtems_a_SOURCES += src/taskident.c librtems_a_SOURCES += src/taskinitusers.c librtems_a_SOURCES += src/taskissuspended.c +librtems_a_SOURCES += src/taskiterate.c librtems_a_SOURCES += src/taskmode.c librtems_a_SOURCES += src/taskrestart.c librtems_a_SOURCES += src/taskresume.c diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h index 0eaaeca4a3..180e50eed7 100644 --- a/cpukit/rtems/include/rtems/rtems/tasks.h +++ b/cpukit/rtems/include/rtems/rtems/tasks.h @@ -513,6 +513,38 @@ rtems_status_code rtems_task_set_scheduler( rtems_id rtems_task_self(void); /** + * @brief Task visitor. + * + * @param[in] tcb The task control block. + * @param[in] arg The visitor argument. + * + * @retval true Stop the iteration. + * @retval false Otherwise. + * + * @see rtems_task_iterate(). + */ +typedef bool ( *rtems_task_visitor )( rtems_tcb *tcb, void *arg ); + +/** + * @brief Iterates over all tasks in the system. + * + * This operation covers all tasks of all APIs. + * + * Must be called from task context. This operation obtains and releases the + * objects allocator lock. The task visitor is called while owning the objects + * allocator lock. It is possible to perform blocking operations in the task + * visitor, however, take care that no deadlocks via the object allocator lock + * can occur. + * + * @param[in] visitor The task visitor. + * @param[in] arg The visitor argument. + */ +void rtems_task_iterate( + rtems_task_visitor visitor, + void *arg +); + +/** * @brief Identifies a scheduler by its name. * * The scheduler name is determined by the scheduler configuration. diff --git a/cpukit/rtems/src/taskiterate.c b/cpukit/rtems/src/taskiterate.c new file mode 100644 index 0000000000..853551b599 --- /dev/null +++ b/cpukit/rtems/src/taskiterate.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/rtems/tasks.h> +#include <rtems/score/threadimpl.h> +#include <rtems/score/objectimpl.h> + +void rtems_task_iterate( + rtems_task_visitor visitor, + void *arg +) +{ + _Objects_Allocator_lock(); + _Thread_Iterate( visitor, arg ); + _Objects_Allocator_unlock(); +} |