summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/thread.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-17 16:28:50 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-24 14:35:04 +0100
commit2e9c3d5e2944a8782eac8a12d23af7559873ad0a (patch)
treed19a9f00f4ca76811e3e4d25af5b48f50a2d47c1 /cpukit/score/include/rtems/score/thread.h
parentcpukit/libmisc/utf8proc/utf8proc.c: Avoid overflow (diff)
downloadrtems-2e9c3d5e2944a8782eac8a12d23af7559873ad0a.tar.bz2
score: Add thread priority change handler
Since the thread current priority change and thread queue requeue is performed in one critical section it is possible to simplify the thread queue requeue procedure. Add a thread queue agnostic thread priority change handler so that we are able to use alternative thread queue implementations. Update #2273.
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/thread.h57
1 files changed, 52 insertions, 5 deletions
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 11f60f324b..ee7886c934 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -374,6 +374,56 @@ typedef enum {
/** This macro defines the last API which has threads. */
#define THREAD_API_LAST THREAD_API_POSIX
+/**
+ * @brief Priority change handler.
+ *
+ * @param[in] the_thread The thread.
+ * @param[in] new_priority The new priority value.
+ * @param[in] context The handler context.
+ *
+ * @see _Thread_Priority_set_change_handler().
+ */
+typedef void (*Thread_Priority_change_handler)(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ void *context
+);
+
+/**
+ * @brief Thread priority control.
+ */
+typedef struct {
+ /**
+ * @brief Generation of the current priority value.
+ *
+ * It is used in _Thread_Change_priority() to serialize the update of
+ * priority related data structures.
+ */
+ uint32_t generation;
+
+ /**
+ * @brief Priority change handler.
+ *
+ * Called by _Thread_Change_priority() to notify a thread about a priority
+ * change. In case this thread waits currently for a resource the handler
+ * may adjust its data structures according to the new priority value. This
+ * handler must not be NULL, instead the default handler
+ * _Thread_Priority_change_do_nothing() should be used in case nothing needs
+ * to be done during a priority change.
+ *
+ * @see _Thread_Priority_set_change_handler() and
+ * _Thread_Priority_restore_default_change_handler().
+ */
+ Thread_Priority_change_handler change_handler;
+
+ /**
+ * @brief Context for priority change handler.
+ *
+ * @see _Thread_Priority_set_change_handler().
+ */
+ void *change_handler_context;
+} Thread_Priority_control;
+
typedef struct Thread_Action Thread_Action;
/**
@@ -584,12 +634,9 @@ struct Thread_Control_struct {
Priority_Control real_priority;
/**
- * @brief Generation of the current priority value.
- *
- * It is used in _Thread_Change_priority() to serialize the update of
- * priority related data structures.
+ * @brief Thread priority control.
*/
- uint32_t priority_generation;
+ Thread_Priority_control Priority;
/** This field is the number of mutexes currently held by this thread. */
uint32_t resource_count;