summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-21 10:17:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-19 12:00:45 +0200
commit568af83542eec9343c24d417ed6a219d22046233 (patch)
treef66fde552c81c31930df66cb8a00444efeb0f30a /cpukit/score/src
parentscore: Add Thread_queue_Control::Lock (diff)
downloadrtems-568af83542eec9343c24d417ed6a219d22046233.tar.bz2
score: Add Thread_queue_Operations
Replace the Thread_Priority_control with more general Thread_queue_Operations which will be used for generic priority change, timeout, signal and wait queue operations in the future. Update #2273.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/thread.c2
-rw-r--r--cpukit/score/src/threadchangepriority.c10
-rw-r--r--cpukit/score/src/threadinitialize.c13
-rw-r--r--cpukit/score/src/threadqenqueue.c30
-rw-r--r--cpukit/score/src/threadqops.c56
5 files changed, 70 insertions, 41 deletions
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index 88b3272d0a..f4c53079d5 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -32,7 +32,7 @@ THREAD_OFFSET_ASSERT( RBNode );
THREAD_OFFSET_ASSERT( current_state );
THREAD_OFFSET_ASSERT( current_priority );
THREAD_OFFSET_ASSERT( real_priority );
-THREAD_OFFSET_ASSERT( Priority );
+THREAD_OFFSET_ASSERT( priority_generation );
THREAD_OFFSET_ASSERT( resource_count );
THREAD_OFFSET_ASSERT( Wait );
THREAD_OFFSET_ASSERT( Timer );
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c
index a011a8f5e5..3223544fe3 100644
--- a/cpukit/score/src/threadchangepriority.c
+++ b/cpukit/score/src/threadchangepriority.c
@@ -41,21 +41,21 @@ void _Thread_Change_priority(
if ( the_thread->current_priority != new_priority ) {
uint32_t my_generation;
- my_generation = the_thread->Priority.generation + 1;
+ my_generation = the_thread->priority_generation + 1;
the_thread->current_priority = new_priority;
- the_thread->Priority.generation = my_generation;
+ the_thread->priority_generation = my_generation;
- (*the_thread->Priority.change_handler)(
+ ( *the_thread->Wait.operations->priority_change )(
the_thread,
new_priority,
- the_thread->Priority.change_handler_context
+ the_thread->Wait.queue
);
_Thread_Lock_release( lock, &lock_context );
_Scheduler_Acquire( the_thread, &lock_context );
- if ( the_thread->Priority.generation == my_generation ) {
+ if ( the_thread->priority_generation == my_generation ) {
if ( _States_Is_ready( the_thread->current_state ) ) {
_Scheduler_Change_priority(
the_thread,
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 27c3f06af7..9f5df257aa 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -29,15 +29,6 @@
#include <rtems/score/cpusetimpl.h>
#include <rtems/config.h>
-void _Thread_Priority_change_do_nothing(
- Thread_Control *the_thread,
- Priority_Control new_priority,
- void *context
-)
-{
- /* Do nothing */
-}
-
bool _Thread_Initialize(
Objects_Information *information,
Thread_Control *the_thread,
@@ -208,10 +199,10 @@ bool _Thread_Initialize(
the_thread->current_state = STATES_DORMANT;
the_thread->Wait.queue = NULL;
+ the_thread->Wait.operations = &_Thread_queue_Operations_default;
the_thread->resource_count = 0;
the_thread->real_priority = priority;
- the_thread->Priority.generation = 0;
- the_thread->Priority.change_handler = _Thread_Priority_change_do_nothing;
+ the_thread->priority_generation = 0;
the_thread->Start.initial_priority = priority;
_Thread_Wait_flags_set( the_thread, THREAD_WAIT_FLAGS_INITIAL );
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 76eaa30dde..6cc731e282 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -46,7 +46,7 @@ static void _Thread_blocking_operation_Finalize(
/*
* The thread is not waiting on anything after this completes.
*/
- the_thread->Wait.queue = NULL;
+ _Thread_Wait_set_queue( the_thread, NULL );
_Thread_Lock_restore_default( the_thread );
@@ -75,23 +75,6 @@ static void _Thread_blocking_operation_Finalize(
#endif
}
-static void _Thread_queue_Requeue_priority(
- Thread_Control *the_thread,
- Priority_Control new_priority,
- void *context
-)
-{
- Thread_queue_Control *tq = context;
-
- _RBTree_Extract( &tq->Queues.Priority, &the_thread->RBNode );
- _RBTree_Insert(
- &tq->Queues.Priority,
- &the_thread->RBNode,
- _Thread_queue_Compare_priority,
- false
- );
-}
-
void _Thread_queue_Enqueue_critical(
Thread_queue_Control *the_thread_queue,
Thread_Control *the_thread,
@@ -105,7 +88,7 @@ void _Thread_queue_Enqueue_critical(
_Thread_Lock_set( the_thread, &the_thread_queue->Lock );
the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED;
- the_thread->Wait.queue = the_thread_queue;
+ _Thread_Wait_set_queue( the_thread, the_thread_queue );
_Thread_queue_Release( the_thread_queue, lock_context );
@@ -153,10 +136,9 @@ void _Thread_queue_Enqueue_critical(
&the_thread->Object.Node
);
} else { /* must be THREAD_QUEUE_DISCIPLINE_PRIORITY */
- _Thread_Priority_set_change_handler(
+ _Thread_Wait_set_operations(
the_thread,
- _Thread_queue_Requeue_priority,
- the_thread_queue
+ &_Thread_queue_Operations_priority
);
_RBTree_Insert(
&the_thread_queue->Queues.Priority,
@@ -206,7 +188,7 @@ void _Thread_queue_Extract_with_return_code(
&the_thread->Wait.queue->Queues.Priority,
&the_thread->RBNode
);
- _Thread_Priority_restore_default_change_handler( the_thread );
+ _Thread_Wait_restore_default_operations( the_thread );
}
the_thread->Wait.return_code = return_code;
@@ -252,7 +234,7 @@ Thread_Control *_Thread_queue_Dequeue(
first = _RBTree_Get( &the_thread_queue->Queues.Priority, RBT_LEFT );
if ( first ) {
the_thread = THREAD_RBTREE_NODE_TO_THREAD( first );
- _Thread_Priority_restore_default_change_handler( the_thread );
+ _Thread_Wait_restore_default_operations( the_thread );
}
}
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c
new file mode 100644
index 0000000000..561480130a
--- /dev/null
+++ b/cpukit/score/src/threadqops.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015 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/score/threadimpl.h>
+#include <rtems/score/rbtreeimpl.h>
+
+static void _Thread_queue_Do_nothing_priority_change(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Thread_queue_Control *queue
+)
+{
+ /* Do nothing */
+}
+
+static void _Thread_queue_Priority_priority_change(
+ Thread_Control *the_thread,
+ Priority_Control new_priority,
+ Thread_queue_Control *queue
+)
+{
+ _RBTree_Extract( &queue->Queues.Priority, &the_thread->RBNode );
+ _RBTree_Insert(
+ &queue->Queues.Priority,
+ &the_thread->RBNode,
+ _Thread_queue_Compare_priority,
+ false
+ );
+}
+
+const Thread_queue_Operations _Thread_queue_Operations_default = {
+ .priority_change = _Thread_queue_Do_nothing_priority_change
+};
+
+const Thread_queue_Operations _Thread_queue_Operations_FIFO = {
+ .priority_change = _Thread_queue_Do_nothing_priority_change
+};
+
+const Thread_queue_Operations _Thread_queue_Operations_priority = {
+ .priority_change = _Thread_queue_Priority_priority_change
+};