[rtems commit] score: Add _Thread_queue_Dispatch_disable()

Sebastian Huber sebh at rtems.org
Wed Oct 11 05:39:03 UTC 2017


Module:    rtems
Branch:    master
Commit:    db3a3decbd387a5f9bbac7089caa479c75589b74
Changeset: http://git.rtems.org/rtems/commit/?id=db3a3decbd387a5f9bbac7089caa479c75589b74

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Oct 10 10:03:48 2017 +0200

score: Add _Thread_queue_Dispatch_disable()

---

 cpukit/posix/include/rtems/posix/muteximpl.h     |  8 ++------
 cpukit/posix/src/pthreadsetschedparam.c          |  4 +---
 cpukit/posix/src/pthreadsetschedprio.c           |  4 +---
 cpukit/rtems/src/semsetpriority.c                |  4 +---
 cpukit/rtems/src/taskdelete.c                    |  4 +---
 cpukit/rtems/src/tasksetpriority.c               |  4 +---
 cpukit/rtems/src/tasksetscheduler.c              |  5 +----
 cpukit/score/include/rtems/score/coremuteximpl.h |  4 +---
 cpukit/score/include/rtems/score/mrspimpl.h      |  4 +---
 cpukit/score/include/rtems/score/threadqimpl.h   | 10 ++++++++++
 cpukit/score/src/threadqenqueue.c                | 16 ++++------------
 cpukit/score/src/threadqflush.c                  |  4 +---
 12 files changed, 25 insertions(+), 46 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h
index 833938b..f146e0d 100644
--- a/cpukit/posix/include/rtems/posix/muteximpl.h
+++ b/cpukit/posix/include/rtems/posix/muteximpl.h
@@ -321,9 +321,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner(
   );
   _Thread_Wait_release_default_critical( owner, &lock_context );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _POSIX_Mutex_Release( the_mutex, queue_context );
   _Thread_Priority_update( queue_context );
   _Thread_Dispatch_enable( cpu_self );
@@ -413,9 +411,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender(
   );
   _Thread_Wait_release_default_critical( executing, &lock_context );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
 
   heads = the_mutex->Recursive.Mutex.Queue.Queue.heads;
 
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index 5d33f1d..38bb0ad 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -155,9 +155,7 @@ int pthread_setschedparam(
     budget_callout,
     &queue_context
   );
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context.Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( &queue_context );
   _Thread_Wait_release( the_thread, &queue_context );
   _Thread_Priority_update( &queue_context );
   _Thread_Dispatch_enable( cpu_self );
diff --git a/cpukit/posix/src/pthreadsetschedprio.c b/cpukit/posix/src/pthreadsetschedprio.c
index ff7bd5c..01dbd86 100644
--- a/cpukit/posix/src/pthreadsetschedprio.c
+++ b/cpukit/posix/src/pthreadsetschedprio.c
@@ -53,9 +53,7 @@ int pthread_setschedprio( pthread_t thread, int prio )
     &queue_context
   );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context.Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( &queue_context );
   _Thread_Wait_release( the_thread, &queue_context );
 
   _Thread_Priority_update( &queue_context );
diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c
index d67e816..508dca5 100644
--- a/cpukit/rtems/src/semsetpriority.c
+++ b/cpukit/rtems/src/semsetpriority.c
@@ -110,9 +110,7 @@ static rtems_status_code _Semaphore_Set_priority(
       break;
   }
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_queue_Release(
     &the_semaphore->Core_control.Wait_queue,
     queue_context
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index de57fb3..b7c2cd5 100644
--- a/cpukit/rtems/src/taskdelete.c
+++ b/cpukit/rtems/src/taskdelete.c
@@ -47,9 +47,7 @@ rtems_status_code rtems_task_delete(
   if ( the_thread == executing ) {
     Per_CPU_Control *cpu_self;
 
-    cpu_self = _Thread_Dispatch_disable_critical(
-      &context.Base.Lock_context.Lock_context
-    );
+    cpu_self = _Thread_queue_Dispatch_disable( &context.Base );
     _ISR_lock_ISR_enable( &context.Base.Lock_context.Lock_context );
 
     /*
diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c
index c17ff1c..0651d49 100644
--- a/cpukit/rtems/src/tasksetpriority.c
+++ b/cpukit/rtems/src/tasksetpriority.c
@@ -51,9 +51,7 @@ static rtems_status_code _RTEMS_tasks_Set_priority(
     false,
     queue_context
   );
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_Wait_release( the_thread, queue_context );
   _Thread_Priority_update( queue_context );
   _Thread_Dispatch_enable( cpu_self );
diff --git a/cpukit/rtems/src/tasksetscheduler.c b/cpukit/rtems/src/tasksetscheduler.c
index f3b7143..c5e1878 100644
--- a/cpukit/rtems/src/tasksetscheduler.c
+++ b/cpukit/rtems/src/tasksetscheduler.c
@@ -58,10 +58,7 @@ rtems_status_code rtems_task_set_scheduler(
     return RTEMS_INVALID_ID;
   }
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context.Lock_context.Lock_context
-  );
-
+  cpu_self = _Thread_queue_Dispatch_disable( &queue_context );
   _Thread_Wait_acquire_critical( the_thread, &queue_context );
   _Thread_State_acquire_critical( the_thread, &state_context );
 
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index e524539..78fafca6 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -305,9 +305,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner(
   );
   _Thread_Wait_release_default_critical( owner, &lock_context );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context );
   _Thread_Priority_update( queue_context );
   _Thread_Dispatch_enable( cpu_self );
diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h
index b951416..b9c7441 100644
--- a/cpukit/score/include/rtems/score/mrspimpl.h
+++ b/cpukit/score/include/rtems/score/mrspimpl.h
@@ -179,9 +179,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership(
   }
 
   _MRSP_Set_owner( mrsp, executing );
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _MRSP_Release( mrsp, queue_context );
   _Thread_Priority_and_sticky_update( executing, 1 );
   _Thread_Dispatch_enable( cpu_self );
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index c4a22a5..6006707 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -26,6 +26,7 @@
 #include <rtems/score/smp.h>
 #include <rtems/score/status.h>
 #include <rtems/score/thread.h>
+#include <rtems/score/threaddispatch.h>
 
 #if defined(RTEMS_DEBUG)
 #include <string.h>
@@ -277,6 +278,15 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(
   );
 }
 
+RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable(
+  Thread_queue_Context *queue_context
+)
+{
+  return _Thread_Dispatch_disable_critical(
+    &queue_context->Lock_context.Lock_context
+  );
+}
+
 /**
  * @brief Sets the MP callout in the thread queue context.
  *
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index bf08d78..1f5a9c1 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -445,9 +445,7 @@ void _Thread_queue_Enqueue(
 
   the_thread->Wait.return_code = STATUS_SUCCESSFUL;
   _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK );
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
 
   ( *queue_context->enqueue_callout )( queue, the_thread, queue_context );
@@ -513,9 +511,7 @@ Status_Control _Thread_queue_Enqueue_sticky(
 
   the_thread->Wait.return_code = STATUS_SUCCESSFUL;
   _Thread_Wait_flags_set( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK );
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
 
   if ( cpu_self->thread_dispatch_disable_level != 1 ) {
@@ -715,9 +711,7 @@ void _Thread_queue_Surrender(
 
   unblock = _Thread_queue_Make_ready_again( new_owner );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_queue_Queue_release(
     queue,
     &queue_context->Lock_context.Lock_context
@@ -756,9 +750,7 @@ void _Thread_queue_Surrender_sticky(
   queue->owner = new_owner;
   _Thread_queue_Make_ready_again( new_owner );
 
-  cpu_self = _Thread_Dispatch_disable_critical(
-    &queue_context->Lock_context.Lock_context
-  );
+  cpu_self = _Thread_queue_Dispatch_disable( queue_context );
   _Thread_queue_Queue_release(
     queue,
     &queue_context->Lock_context.Lock_context
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index 6c9ca98..8135e67 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -115,9 +115,7 @@ size_t _Thread_queue_Flush_critical(
   if ( node != tail ) {
     Per_CPU_Control *cpu_self;
 
-    cpu_self = _Thread_Dispatch_disable_critical(
-      &queue_context->Lock_context.Lock_context
-    );
+    cpu_self = _Thread_queue_Dispatch_disable( queue_context );
     _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
 
     do {




More information about the vc mailing list