summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadqextract.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-11 09:00:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-23 11:00:28 +0100
commit2e56aabdb1035bd102713382dd03e9b0955eb1f2 (patch)
tree9296c9921413c1bfc34617b369c785a7a7d9806b /cpukit/score/src/threadqextract.c
parentscore: Simplify thread wait state handling (diff)
downloadrtems-2e56aabdb1035bd102713382dd03e9b0955eb1f2.tar.bz2
score: Move _Thread_queue_Extract()
Move _Thread_queue_Extract() since this function is not used by the core services (threads, semaphores, mutexes, message queues). Update #4546.
Diffstat (limited to '')
-rw-r--r--cpukit/score/src/threadqextract.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cpukit/score/src/threadqextract.c b/cpukit/score/src/threadqextract.c
new file mode 100644
index 0000000000..0c6efedbaf
--- /dev/null
+++ b/cpukit/score/src/threadqextract.c
@@ -0,0 +1,57 @@
+/**
+ * @file
+ *
+ * @ingroup RTEMSScoreThreadQueue
+ *
+ * @brief This source file contains the implementation of
+ * _Thread_queue_Extract().
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Copyright (c) 2015, 2016 embedded brains GmbH.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/threadqimpl.h>
+#include <rtems/score/threadimpl.h>
+
+void _Thread_queue_Extract( Thread_Control *the_thread )
+{
+ Thread_queue_Context queue_context;
+ Thread_queue_Queue *queue;
+
+ _Thread_queue_Context_initialize( &queue_context );
+ _Thread_queue_Context_clear_priority_updates( &queue_context );
+ _Thread_Wait_acquire( the_thread, &queue_context );
+
+ queue = the_thread->Wait.queue;
+
+ if ( queue != NULL ) {
+ _Thread_Wait_remove_request( the_thread, &queue_context.Lock_context );
+ _Thread_queue_Context_set_MP_callout(
+ &queue_context,
+ _Thread_queue_MP_callout_do_nothing
+ );
+#if defined(RTEMS_MULTIPROCESSING)
+ _Thread_queue_MP_set_callout( the_thread, &queue_context );
+#endif
+ ( *the_thread->Wait.operations->extract )(
+ queue,
+ the_thread,
+ &queue_context
+ );
+ _Thread_queue_Resume( queue, the_thread, &queue_context );
+ } else {
+ _Thread_Wait_release( the_thread, &queue_context );
+ }
+}