[PATCH 9/9] score: Add and use _Objects_Release()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jun 5 15:22:07 UTC 2013


Add and use _Objects_Release_without_thread_dispatch().  These two
functions pair with the _Objects_Get() function.  This helps to
introduce object specific SMP locks to avoid lock contention.
---
 cpukit/libfs/src/pipe/fifo.c                      |   16 ++++---
 cpukit/posix/src/canceleval.c                     |    3 +-
 cpukit/posix/src/conddestroy.c                    |    4 +-
 cpukit/posix/src/condsignalsupp.c                 |    2 +-
 cpukit/posix/src/condwaitsupp.c                   |   14 ++++---
 cpukit/posix/src/keydelete.c                      |    2 +-
 cpukit/posix/src/keygetspecific.c                 |    2 +-
 cpukit/posix/src/keysetspecific.c                 |    2 +-
 cpukit/posix/src/mqueueclose.c                    |    2 +-
 cpukit/posix/src/mqueuegetattr.c                  |    2 +-
 cpukit/posix/src/mqueuenotify.c                   |    4 +-
 cpukit/posix/src/mqueuerecvsupp.c                 |    6 +-
 cpukit/posix/src/mqueuesendsupp.c                 |    4 +-
 cpukit/posix/src/mqueuesetattr.c                  |    2 +-
 cpukit/posix/src/mutexdestroy.c                   |    4 +-
 cpukit/posix/src/mutexgetprioceiling.c            |    2 +-
 cpukit/posix/src/mutexinit.c                      |    2 +-
 cpukit/posix/src/mutexsetprioceiling.c            |    2 +-
 cpukit/posix/src/mutexunlock.c                    |    2 +-
 cpukit/posix/src/pbarrierdestroy.c                |    4 +-
 cpukit/posix/src/pbarrierwait.c                   |    2 +-
 cpukit/posix/src/prwlockdestroy.c                 |    4 +-
 cpukit/posix/src/prwlockrdlock.c                  |    2 +-
 cpukit/posix/src/prwlocktimedrdlock.c             |    2 +-
 cpukit/posix/src/prwlocktimedwrlock.c             |    2 +-
 cpukit/posix/src/prwlocktryrdlock.c               |    2 +-
 cpukit/posix/src/prwlocktrywrlock.c               |    2 +-
 cpukit/posix/src/prwlockunlock.c                  |    2 +-
 cpukit/posix/src/prwlockwrlock.c                  |    2 +-
 cpukit/posix/src/pspindestroy.c                   |    4 +-
 cpukit/posix/src/pspinlock.c                      |    2 +-
 cpukit/posix/src/pspintrylock.c                   |    2 +-
 cpukit/posix/src/pspinunlock.c                    |    2 +-
 cpukit/posix/src/pthreaddetach.c                  |    2 +-
 cpukit/posix/src/pthreadequal.c                   |   18 +++++----
 cpukit/posix/src/pthreadexit.c                    |    2 +
 cpukit/posix/src/pthreadgetschedparam.c           |    2 +-
 cpukit/posix/src/pthreadjoin.c                    |    6 +-
 cpukit/posix/src/pthreadkill.c                    |    6 +-
 cpukit/posix/src/pthreadsetschedparam.c           |    2 +-
 cpukit/posix/src/semaphorewaitsupp.c              |    2 +-
 cpukit/posix/src/semclose.c                       |    2 +-
 cpukit/posix/src/semdestroy.c                     |    4 +-
 cpukit/posix/src/semgetvalue.c                    |    2 +-
 cpukit/posix/src/sempost.c                        |    2 +-
 cpukit/posix/src/timercreate.c                    |    4 +-
 cpukit/posix/src/timerdelete.c                    |    2 +-
 cpukit/posix/src/timergetoverrun.c                |    2 +-
 cpukit/posix/src/timergettime.c                   |    2 +-
 cpukit/posix/src/timersettime.c                   |    6 +-
 cpukit/rtems/src/barrierdelete.c                  |    2 +-
 cpukit/rtems/src/barrierrelease.c                 |    2 +-
 cpukit/rtems/src/barrierwait.c                    |    2 +-
 cpukit/rtems/src/dpmemdelete.c                    |    2 +-
 cpukit/rtems/src/dpmemexternal2internal.c         |    2 +-
 cpukit/rtems/src/dpmeminternal2external.c         |    2 +-
 cpukit/rtems/src/eventsend.c                      |    2 +-
 cpukit/rtems/src/eventtimeout.c                   |    4 +-
 cpukit/rtems/src/msgqbroadcast.c                  |    2 +-
 cpukit/rtems/src/msgqdelete.c                     |    2 +-
 cpukit/rtems/src/msgqflush.c                      |    2 +-
 cpukit/rtems/src/msgqgetnumberpending.c           |    2 +-
 cpukit/rtems/src/msgqreceive.c                    |    2 +-
 cpukit/rtems/src/msgqsend.c                       |    2 +-
 cpukit/rtems/src/msgqurgent.c                     |    2 +-
 cpukit/rtems/src/partdelete.c                     |    4 +-
 cpukit/rtems/src/partgetbuffer.c                  |    4 +-
 cpukit/rtems/src/partreturnbuffer.c               |    4 +-
 cpukit/rtems/src/ratemoncancel.c                  |    4 +-
 cpukit/rtems/src/ratemondelete.c                  |    2 +-
 cpukit/rtems/src/ratemongetstatistics.c           |    2 +-
 cpukit/rtems/src/ratemongetstatus.c               |    4 +-
 cpukit/rtems/src/ratemonperiod.c                  |   10 ++--
 cpukit/rtems/src/ratemonresetstatistics.c         |    2 +-
 cpukit/rtems/src/ratemontimeout.c                 |    2 +-
 cpukit/rtems/src/regiongetsegment.c               |    3 +-
 cpukit/rtems/src/rtemsobjectsetname.c             |    2 +-
 cpukit/rtems/src/semdelete.c                      |    4 +-
 cpukit/rtems/src/semflush.c                       |    2 +-
 cpukit/rtems/src/semrelease.c                     |    4 +-
 cpukit/rtems/src/signalsend.c                     |    4 +-
 cpukit/rtems/src/systemeventsend.c                |    2 +-
 cpukit/rtems/src/taskdelete.c                     |   13 +++---
 cpukit/rtems/src/taskgetnote.c                    |    2 +-
 cpukit/rtems/src/taskissuspended.c                |    4 +-
 cpukit/rtems/src/taskrestart.c                    |    4 +-
 cpukit/rtems/src/taskresume.c                     |    4 +-
 cpukit/rtems/src/tasksetnote.c                    |    2 +-
 cpukit/rtems/src/tasksetpriority.c                |    2 +-
 cpukit/rtems/src/taskstart.c                      |    4 +-
 cpukit/rtems/src/tasksuspend.c                    |    4 +-
 cpukit/rtems/src/taskvariableadd.c                |    6 +-
 cpukit/rtems/src/taskvariabledelete.c             |    4 +-
 cpukit/rtems/src/taskvariableget.c                |    4 +-
 cpukit/rtems/src/timercancel.c                    |    2 +-
 cpukit/rtems/src/timerdelete.c                    |    2 +-
 cpukit/rtems/src/timerfireafter.c                 |    4 +-
 cpukit/rtems/src/timerfirewhen.c                  |    2 +-
 cpukit/rtems/src/timergetinfo.c                   |    2 +-
 cpukit/rtems/src/timerreset.c                     |    4 +-
 cpukit/rtems/src/timerserverfireafter.c           |    4 +-
 cpukit/rtems/src/timerserverfirewhen.c            |    2 +-
 cpukit/sapi/src/extensiondelete.c                 |    2 +-
 cpukit/score/inline/rtems/score/object.inl        |   29 ++++++++++++++
 cpukit/score/src/corerwlocktimeout.c              |    2 +-
 cpukit/score/src/mpci.c                           |    2 +-
 cpukit/score/src/objectgetnameasstring.c          |    2 +-
 cpukit/score/src/objectidtoname.c                 |    2 +-
 cpukit/score/src/schedulercbsattachthread.c       |   42 +++++++++++---------
 cpukit/score/src/schedulercbsdetachthread.c       |   28 +++++++-------
 cpukit/score/src/schedulercbsgetexecutiontime.c   |    2 +-
 cpukit/score/src/schedulercbsgetremainingbudget.c |    2 +-
 cpukit/score/src/threaddelayended.c               |    2 +-
 cpukit/score/src/threadqtimeout.c                 |    2 +-
 114 files changed, 252 insertions(+), 208 deletions(-)

diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 3883685..437b99a 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -74,14 +74,16 @@ static rtems_id pipe_semaphore = RTEMS_ID_NONE;
 /* Set barriers to be interruptible by signals. */
 static void pipe_interruptible(pipe_control_t *pipe)
 {
-  Objects_Locations location;
+  Objects_Locations  location;
+  Barrier_Control   *the_barrier;
 
-  _Barrier_Get(pipe->readBarrier, &location)->Barrier.Wait_queue.state
-    |= STATES_INTERRUPTIBLE_BY_SIGNAL;
-  _Thread_Enable_dispatch();
-  _Barrier_Get(pipe->writeBarrier, &location)->Barrier.Wait_queue.state
-    |= STATES_INTERRUPTIBLE_BY_SIGNAL;
-  _Thread_Enable_dispatch();
+  the_barrier = _Barrier_Get(pipe->readBarrier, &location);
+  the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL;
+  _Objects_Release( &the_barrier->Object );
+
+  the_barrier = _Barrier_Get(pipe->writeBarrier, &location);
+  the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL;
+  _Objects_Release( &the_barrier->Object );
 }
 #endif
 
diff --git a/cpukit/posix/src/canceleval.c b/cpukit/posix/src/canceleval.c
index 973d2a7..c9791d5 100644
--- a/cpukit/posix/src/canceleval.c
+++ b/cpukit/posix/src/canceleval.c
@@ -35,9 +35,10 @@ void _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch(
   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
        thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
        thread_support->cancelation_requested ) {
+    /* FIXME: This path is broken on SMP */
     _Thread_Unnest_dispatch();
     _POSIX_Thread_Exit( the_thread, PTHREAD_CANCELED );
   } else
-    _Thread_Enable_dispatch();
+    _Objects_Release( &the_thread->Object );
 
 }
diff --git a/cpukit/posix/src/conddestroy.c b/cpukit/posix/src/conddestroy.c
index 99f6056..f6c98e4 100644
--- a/cpukit/posix/src/conddestroy.c
+++ b/cpukit/posix/src/conddestroy.c
@@ -46,7 +46,7 @@ int pthread_cond_destroy(
     case OBJECTS_LOCAL:
 
       if ( _Thread_queue_First( &the_cond->Wait_queue ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_cond->Object );
         return EBUSY;
       }
 
@@ -56,7 +56,7 @@ int pthread_cond_destroy(
       );
 
       _POSIX_Condition_variables_Free( the_cond );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_cond->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/condsignalsupp.c b/cpukit/posix/src/condsignalsupp.c
index 36bb60e..4d752af 100644
--- a/cpukit/posix/src/condsignalsupp.c
+++ b/cpukit/posix/src/condsignalsupp.c
@@ -55,7 +55,7 @@ int _POSIX_Condition_variables_Signal_support(
           the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
       } while ( is_broadcast && the_thread );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_cond->Object );
 
       return 0;
 
diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index 91bdc32..290ea99 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -37,15 +37,17 @@ int _POSIX_Condition_variables_Wait_support(
 )
 {
   register POSIX_Condition_variables_Control *the_cond;
+  POSIX_Mutex_Control                        *the_mutex;
   Objects_Locations                           location;
   int                                         status;
   int                                         mutex_status;
 
-  if ( !_POSIX_Mutex_Get( mutex, &location ) ) {
+  the_mutex = _POSIX_Mutex_Get( mutex, &location );
+  if ( !the_mutex ) {
      return EINVAL;
   }
 
-  _Thread_Unnest_dispatch();
+  _Objects_Release_without_thread_dispatch( &the_mutex->Object );
 
   the_cond = _POSIX_Condition_variables_Get( cond, &location );
   switch ( location ) {
@@ -53,14 +55,14 @@ int _POSIX_Condition_variables_Wait_support(
     case OBJECTS_LOCAL:
 
       if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_cond->Object );
         return EINVAL;
       }
 
       (void) pthread_mutex_unlock( mutex );
 /* XXX ignore this for now  since behavior is undefined
       if ( mutex_status ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_cond->Object );
         return EINVAL;
       }
 */
@@ -75,7 +77,7 @@ int _POSIX_Condition_variables_Wait_support(
 
         _Thread_queue_Enqueue( &the_cond->Wait_queue, timeout );
 
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_cond->Object );
 
         /*
          *  Switch ourself out because we blocked as a result of the
@@ -94,7 +96,7 @@ int _POSIX_Condition_variables_Wait_support(
           status = 0;
 
       } else {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_cond->Object );
         status = ETIMEDOUT;
       }
 
diff --git a/cpukit/posix/src/keydelete.c b/cpukit/posix/src/keydelete.c
index 5ef6261..0fc07bd 100644
--- a/cpukit/posix/src/keydelete.c
+++ b/cpukit/posix/src/keydelete.c
@@ -51,7 +51,7 @@ int pthread_key_delete(
        *         of the application to free the memory.
        */
       _POSIX_Keys_Free( the_key );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_key->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c
index debad83..f91bf0b 100644
--- a/cpukit/posix/src/keygetspecific.c
+++ b/cpukit/posix/src/keygetspecific.c
@@ -49,7 +49,7 @@ void *pthread_getspecific(
       api      = _Objects_Get_API( _Thread_Executing->Object.id );
       index    = _Objects_Get_index( _Thread_Executing->Object.id );
       key_data = (void *) the_key->Values[ api ][ index ];
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_key->Object );
       return key_data;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/keysetspecific.c b/cpukit/posix/src/keysetspecific.c
index b25e44c..cbb88d0 100644
--- a/cpukit/posix/src/keysetspecific.c
+++ b/cpukit/posix/src/keysetspecific.c
@@ -49,7 +49,7 @@ int pthread_setspecific(
       api   = _Objects_Get_API( _Thread_Executing->Object.id );
       index = _Objects_Get_index( _Thread_Executing->Object.id );
       the_key->Values[ api ][ index ] = (void *) value;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_key->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mqueueclose.c b/cpukit/posix/src/mqueueclose.c
index 4f1bb41..326da69 100644
--- a/cpukit/posix/src/mqueueclose.c
+++ b/cpukit/posix/src/mqueueclose.c
@@ -78,7 +78,7 @@ int mq_close(
         &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
       _POSIX_Message_queue_Free_fd( the_mq_fd );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
       return 0;
    }
 
diff --git a/cpukit/posix/src/mqueuegetattr.c b/cpukit/posix/src/mqueuegetattr.c
index 0f250f1..c0f3d83 100644
--- a/cpukit/posix/src/mqueuegetattr.c
+++ b/cpukit/posix/src/mqueuegetattr.c
@@ -74,7 +74,7 @@ int mq_getattr(
       mqstat->mq_maxmsg  = the_mq->Message_queue.maximum_pending_messages;
       mqstat->mq_curmsgs = the_mq->Message_queue.number_of_pending_messages;
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mqueuenotify.c b/cpukit/posix/src/mqueuenotify.c
index 5387335..9b17181 100644
--- a/cpukit/posix/src/mqueuenotify.c
+++ b/cpukit/posix/src/mqueuenotify.c
@@ -69,7 +69,7 @@ int mq_notify(
 
       if ( notification ) {
         if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_mq_fd->Object );
           rtems_set_errno_and_return_minus_one( EBUSY );
         }
 
@@ -88,7 +88,7 @@ int mq_notify(
 
       }
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mqueuerecvsupp.c b/cpukit/posix/src/mqueuerecvsupp.c
index 5cfce06..6fb29ea 100644
--- a/cpukit/posix/src/mqueuerecvsupp.c
+++ b/cpukit/posix/src/mqueuerecvsupp.c
@@ -59,14 +59,14 @@ ssize_t _POSIX_Message_queue_Receive_support(
 
     case OBJECTS_LOCAL:
       if ( (the_mq_fd->oflag & O_ACCMODE) == O_WRONLY ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_mq_fd->Object );
         rtems_set_errno_and_return_minus_one( EBADF );
       }
 
       the_mq = the_mq_fd->Queue;
 
       if ( msg_len < the_mq->Message_queue.maximum_message_size ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_mq_fd->Object );
         rtems_set_errno_and_return_minus_one( EMSGSIZE );
       }
 
@@ -97,7 +97,7 @@ ssize_t _POSIX_Message_queue_Receive_support(
         timeout
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
       if (msg_prio) {
         *msg_prio = _POSIX_Message_queue_Priority_from_core(
              _Thread_Executing->Wait.count
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 1f9bf63..40455ae 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -77,7 +77,7 @@ int _POSIX_Message_queue_Send_support(
 
     case OBJECTS_LOCAL:
       if ( (the_mq_fd->oflag & O_ACCMODE) == O_RDONLY ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_mq_fd->Object );
         rtems_set_errno_and_return_minus_one( EBADF );
       }
 
@@ -105,7 +105,7 @@ int _POSIX_Message_queue_Send_support(
         timeout    /* no timeout */
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
 
       /*
        *  If we had to block, then this is where the task returns
diff --git a/cpukit/posix/src/mqueuesetattr.c b/cpukit/posix/src/mqueuesetattr.c
index 2fbcd95..2689bb7 100644
--- a/cpukit/posix/src/mqueuesetattr.c
+++ b/cpukit/posix/src/mqueuesetattr.c
@@ -64,7 +64,7 @@ int mq_setattr(
       }
 
       the_mq_fd->oflag = mqstat->mq_flags;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mq_fd->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mutexdestroy.c b/cpukit/posix/src/mutexdestroy.c
index f733ce7..49af97a 100644
--- a/cpukit/posix/src/mutexdestroy.c
+++ b/cpukit/posix/src/mutexdestroy.c
@@ -49,7 +49,7 @@ int pthread_mutex_destroy(
         */
 
       if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_mutex->Object );
         return EBUSY;
       }
 
@@ -58,7 +58,7 @@ int pthread_mutex_destroy(
       _CORE_mutex_Flush( &the_mutex->Mutex, NULL, EINVAL );
 
       _POSIX_Mutex_Free( the_mutex );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mutex->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mutexgetprioceiling.c b/cpukit/posix/src/mutexgetprioceiling.c
index 8355286..f1ea079 100644
--- a/cpukit/posix/src/mutexgetprioceiling.c
+++ b/cpukit/posix/src/mutexgetprioceiling.c
@@ -53,7 +53,7 @@ int pthread_mutex_getprioceiling(
       *prioceiling = _POSIX_Priority_From_core(
         the_mutex->Mutex.Attributes.priority_ceiling
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mutex->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c
index 979e5b8..9e6a382 100644
--- a/cpukit/posix/src/mutexinit.c
+++ b/cpukit/posix/src/mutexinit.c
@@ -85,7 +85,7 @@ int pthread_mutex_init(
       mutex_in_use = _POSIX_Mutex_Get( mutex, &location );
       switch ( location ) {
         case OBJECTS_LOCAL:
-          _Thread_Enable_dispatch();
+          _Objects_Release( &mutex_in_use->Object );
           return EBUSY;
         #if defined(RTEMS_MULTIPROCESSING)
           case OBJECTS_REMOTE:
diff --git a/cpukit/posix/src/mutexsetprioceiling.c b/cpukit/posix/src/mutexsetprioceiling.c
index 920d6fa..aba2c7b 100644
--- a/cpukit/posix/src/mutexsetprioceiling.c
+++ b/cpukit/posix/src/mutexsetprioceiling.c
@@ -80,7 +80,7 @@ int pthread_mutex_setprioceiling(
         the_mutex->Object.id,
         NULL
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mutex->Object );
 
       return 0;
 
diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c
index cfe8bdb..69af84a 100644
--- a/cpukit/posix/src/mutexunlock.c
+++ b/cpukit/posix/src/mutexunlock.c
@@ -54,7 +54,7 @@ int pthread_mutex_unlock(
         the_mutex->Object.id,
         NULL
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_mutex->Object );
       return _POSIX_Mutex_Translate_core_mutex_return_code( status );
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c
index 66f7014..03de622 100644
--- a/cpukit/posix/src/pbarrierdestroy.c
+++ b/cpukit/posix/src/pbarrierdestroy.c
@@ -50,7 +50,7 @@ int pthread_barrier_destroy(
 
     case OBJECTS_LOCAL:
       if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_barrier->Object );
         return EBUSY;
       }
 
@@ -58,7 +58,7 @@ int pthread_barrier_destroy(
 
       _POSIX_Barrier_Free( the_barrier );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_barrier->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c
index e941bf5..1beadec 100644
--- a/cpukit/posix/src/pbarrierwait.c
+++ b/cpukit/posix/src/pbarrierwait.c
@@ -55,7 +55,7 @@ int pthread_barrier_wait(
         0,
         NULL
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_barrier->Object );
       return _POSIX_Barrier_Translate_core_barrier_return_code(
                 _Thread_Executing->Wait.return_code );
 
diff --git a/cpukit/posix/src/prwlockdestroy.c b/cpukit/posix/src/prwlockdestroy.c
index 6c99abf..86f07b8 100644
--- a/cpukit/posix/src/prwlockdestroy.c
+++ b/cpukit/posix/src/prwlockdestroy.c
@@ -52,7 +52,7 @@ int pthread_rwlock_destroy(
        *  If there is at least one thread waiting, then do not delete it.
        */
       if ( _Thread_queue_First( &the_rwlock->RWLock.Wait_queue ) != NULL ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_rwlock->Object );
         return EBUSY;
       }
 
@@ -64,7 +64,7 @@ int pthread_rwlock_destroy(
 
       _POSIX_RWLock_Free( the_rwlock );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c
index 24adcb4..1961233 100644
--- a/cpukit/posix/src/prwlockrdlock.c
+++ b/cpukit/posix/src/prwlockrdlock.c
@@ -56,7 +56,7 @@ int pthread_rwlock_rdlock(
 	NULL
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return _POSIX_RWLock_Translate_core_RWLock_return_code(
         (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
       );
diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c
index 414fec3..b2fa5c0 100644
--- a/cpukit/posix/src/prwlocktimedrdlock.c
+++ b/cpukit/posix/src/prwlocktimedrdlock.c
@@ -82,7 +82,7 @@ int pthread_rwlock_timedrdlock(
 	NULL
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       if ( !do_wait ) {
         if ( _Thread_Executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE ) {
 	  if ( status == POSIX_ABSOLUTE_TIMEOUT_INVALID )
diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c
index 84aa3a0..a864a04 100644
--- a/cpukit/posix/src/prwlocktimedwrlock.c
+++ b/cpukit/posix/src/prwlocktimedwrlock.c
@@ -84,7 +84,7 @@ int pthread_rwlock_timedwrlock(
 	NULL
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       if ( !do_wait &&
            (_Thread_Executing->Wait.return_code == CORE_RWLOCK_UNAVAILABLE) ) {
 	if ( status == POSIX_ABSOLUTE_TIMEOUT_INVALID )
diff --git a/cpukit/posix/src/prwlocktryrdlock.c b/cpukit/posix/src/prwlocktryrdlock.c
index f584677..806af2b 100644
--- a/cpukit/posix/src/prwlocktryrdlock.c
+++ b/cpukit/posix/src/prwlocktryrdlock.c
@@ -61,7 +61,7 @@ int pthread_rwlock_tryrdlock(
       );
 
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return _POSIX_RWLock_Translate_core_RWLock_return_code(
         (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
       );
diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c
index 6b51d17..3ca301e 100644
--- a/cpukit/posix/src/prwlocktrywrlock.c
+++ b/cpukit/posix/src/prwlocktrywrlock.c
@@ -60,7 +60,7 @@ int pthread_rwlock_trywrlock(
 	NULL
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return _POSIX_RWLock_Translate_core_RWLock_return_code(
         (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
       );
diff --git a/cpukit/posix/src/prwlockunlock.c b/cpukit/posix/src/prwlockunlock.c
index d9c2f6f..18c127e 100644
--- a/cpukit/posix/src/prwlockunlock.c
+++ b/cpukit/posix/src/prwlockunlock.c
@@ -55,7 +55,7 @@ int pthread_rwlock_unlock(
 
     case OBJECTS_LOCAL:
       status = _CORE_RWLock_Release( &the_rwlock->RWLock );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return _POSIX_RWLock_Translate_core_RWLock_return_code( status );
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/prwlockwrlock.c b/cpukit/posix/src/prwlockwrlock.c
index 672772e..d400c37 100644
--- a/cpukit/posix/src/prwlockwrlock.c
+++ b/cpukit/posix/src/prwlockwrlock.c
@@ -62,7 +62,7 @@ int pthread_rwlock_wrlock(
 	NULL
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_rwlock->Object );
       return _POSIX_RWLock_Translate_core_RWLock_return_code(
         (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
       );
diff --git a/cpukit/posix/src/pspindestroy.c b/cpukit/posix/src/pspindestroy.c
index f49fd47..1761c92 100644
--- a/cpukit/posix/src/pspindestroy.c
+++ b/cpukit/posix/src/pspindestroy.c
@@ -50,7 +50,7 @@ int pthread_spin_destroy(
 
     case OBJECTS_LOCAL:
       if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_spinlock->Object );
         return EBUSY;
       }
 
@@ -58,7 +58,7 @@ int pthread_spin_destroy(
 
       _POSIX_Spinlock_Free( the_spinlock );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_spinlock->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c
index 3d0aed9..d517727 100644
--- a/cpukit/posix/src/pspinlock.c
+++ b/cpukit/posix/src/pspinlock.c
@@ -49,7 +49,7 @@ int pthread_spin_lock(
 
     case OBJECTS_LOCAL:
       status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, true, 0 );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_spinlock->Object );
       return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pspintrylock.c b/cpukit/posix/src/pspintrylock.c
index 08ace6d..84a291e 100644
--- a/cpukit/posix/src/pspintrylock.c
+++ b/cpukit/posix/src/pspintrylock.c
@@ -53,7 +53,7 @@ int pthread_spin_trylock(
 
     case OBJECTS_LOCAL:
       status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, false, 0 );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_spinlock->Object );
       return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pspinunlock.c b/cpukit/posix/src/pspinunlock.c
index 8f7c5b1..1838ad8 100644
--- a/cpukit/posix/src/pspinunlock.c
+++ b/cpukit/posix/src/pspinunlock.c
@@ -55,7 +55,7 @@ int pthread_spin_unlock(
 
     case OBJECTS_LOCAL:
       status = _CORE_spinlock_Release( &the_spinlock->Spinlock );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_spinlock->Object );
       return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pthreaddetach.c b/cpukit/posix/src/pthreaddetach.c
index 824537e..9d291b7 100644
--- a/cpukit/posix/src/pthreaddetach.c
+++ b/cpukit/posix/src/pthreaddetach.c
@@ -43,7 +43,7 @@ int pthread_detach(
 
       api = the_thread->API_Extensions[ THREAD_API_POSIX ];
       api->detachstate = PTHREAD_CREATE_DETACHED;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pthreadequal.c b/cpukit/posix/src/pthreadequal.c
index 199cc8f..dd113bd 100644
--- a/cpukit/posix/src/pthreadequal.c
+++ b/cpukit/posix/src/pthreadequal.c
@@ -41,8 +41,10 @@ int pthread_equal(
 #ifndef RTEMS_DEBUG
   return _Objects_Are_ids_equal( t1, t2 );
 #else
-  int               status;
-  Objects_Locations location;
+  int                status;
+  Objects_Locations  location;
+  Thread_Control    *thread_1;
+  Thread_Control    *thread_2;
 
   /*
    *  By default this is not a match.
@@ -54,7 +56,7 @@ int pthread_equal(
    *  Validate the first id and return 0 if it is not valid
    */
 
-  (void) _Thread_Get( t1, &location );
+  thread_1 = _Thread_Get( t1, &location );
   switch ( location ) {
 
     case OBJECTS_LOCAL:
@@ -63,21 +65,21 @@ int pthread_equal(
        *  Validate the second id and return 0 if it is not valid
        */
 
-      (void) _Thread_Get( t2, &location );
+      thread_2 = _Thread_Get( t2, &location );
       switch ( location ) {
 
         case OBJECTS_LOCAL:
           status = _Objects_Are_ids_equal( t1, t2 );
-	  _Thread_Unnest_dispatch();
-	  _Thread_Enable_dispatch();
-	  break;
+          _Objects_Release_without_thread_dispatch( &thread_2->Object );
+          _Objects_Release( &thread_1->Object );
+          break;
 
         case OBJECTS_ERROR:
 #if defined(RTEMS_MULTIPROCESSING)
         case OBJECTS_REMOTE:
 #endif
           /* t1 must have been valid so exit the critical section */
-          _Thread_Enable_dispatch();
+          _Objects_Release( &thread_1->Object );
           /* return status == 0 */
           break;
       }
diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c
index 2e995c4..01bcf6f 100644
--- a/cpukit/posix/src/pthreadexit.c
+++ b/cpukit/posix/src/pthreadexit.c
@@ -72,6 +72,7 @@ void _POSIX_Thread_Exit(
             the_thread,
             STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_TRANSIENT
           );
+           /* FIXME: Lock order reversal */
            _RTEMS_Unlock_allocator();
           _Thread_Enable_dispatch();
           /* now waiting for thread to arrive */
@@ -87,6 +88,7 @@ void _POSIX_Thread_Exit(
 
       _POSIX_Threads_Free( the_thread );
 
+     /* FIXME: Lock order reversal */
     _RTEMS_Unlock_allocator();
   _Thread_Enable_dispatch();
 }
diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c
index d681f04..05ef623 100644
--- a/cpukit/posix/src/pthreadgetschedparam.c
+++ b/cpukit/posix/src/pthreadgetschedparam.c
@@ -53,7 +53,7 @@ int pthread_getschedparam(
         param->sched_priority =
           _POSIX_Priority_From_core( the_thread->current_priority );
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 8304aa3..586aa52 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -45,12 +45,12 @@ on_EINTR:
       api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
       if ( api->detachstate == PTHREAD_CREATE_DETACHED ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return EINVAL;
       }
 
       if ( _Thread_Is_executing( the_thread ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return EDEADLK;
       }
 
@@ -70,7 +70,7 @@ on_EINTR:
         _Thread_queue_Enter_critical_section( &api->Join_List );
         _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
 
       if ( _Thread_Executing->Wait.return_code == EINTR )
         goto on_EINTR;
diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c
index e0f3950..e6576b6 100644
--- a/cpukit/posix/src/pthreadkill.c
+++ b/cpukit/posix/src/pthreadkill.c
@@ -60,7 +60,7 @@ int pthread_kill(
       if ( sig ) {
 
         if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_thread->Object );
           return 0;
         }
 
@@ -71,9 +71,9 @@ int pthread_kill(
         (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
 
         if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
-	  _Thread_Dispatch_necessary = true;
+          _Thread_Dispatch_necessary = true;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index 06216f4..4886e4c 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -98,7 +98,7 @@ int pthread_setschedparam(
           break;
       }
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c
index 08a26ee..726eb73 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -51,7 +51,7 @@ int _POSIX_Semaphore_Wait_support(
         blocking,
         timeout
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
 
       if ( !_Thread_Executing->Wait.return_code )
         return 0;
diff --git a/cpukit/posix/src/semclose.c b/cpukit/posix/src/semclose.c
index a9521bd..f11f514 100644
--- a/cpukit/posix/src/semclose.c
+++ b/cpukit/posix/src/semclose.c
@@ -45,7 +45,7 @@ int sem_close(
     case OBJECTS_LOCAL:
       the_semaphore->open_count -= 1;
       _POSIX_Semaphore_Delete( the_semaphore );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c
index 14ba520..5557fac 100644
--- a/cpukit/posix/src/semdestroy.c
+++ b/cpukit/posix/src/semdestroy.c
@@ -48,12 +48,12 @@ int sem_destroy(
        */
 
       if ( the_semaphore->named == true ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_semaphore->Object );
         rtems_set_errno_and_return_minus_one( EINVAL );
       }
 
       _POSIX_Semaphore_Delete( the_semaphore );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/semgetvalue.c b/cpukit/posix/src/semgetvalue.c
index 8ea0bda..974c60f 100644
--- a/cpukit/posix/src/semgetvalue.c
+++ b/cpukit/posix/src/semgetvalue.c
@@ -45,7 +45,7 @@ int sem_getvalue(
 
     case OBJECTS_LOCAL:
       *sval = _CORE_semaphore_Get_count( &the_semaphore->Semaphore );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/sempost.c b/cpukit/posix/src/sempost.c
index 7ce3679..7a6db65 100644
--- a/cpukit/posix/src/sempost.c
+++ b/cpukit/posix/src/sempost.c
@@ -52,7 +52,7 @@ int sem_post(
         NULL
 #endif
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/timercreate.c b/cpukit/posix/src/timercreate.c
index bd52f87..dbcf451 100644
--- a/cpukit/posix/src/timercreate.c
+++ b/cpukit/posix/src/timercreate.c
@@ -72,7 +72,7 @@ int timer_create(
    */
   ptimer = _POSIX_Timer_Allocate();
   if ( !ptimer ) {
-    _Thread_Enable_dispatch();
+    _Objects_Release( &ptimer->Object );
     rtems_set_errno_and_return_minus_one( EAGAIN );
   }
 
@@ -97,6 +97,6 @@ int timer_create(
   _Objects_Open_u32(&_POSIX_Timer_Information, &ptimer->Object, 0);
 
   *timerid  = ptimer->Object.id;
-  _Thread_Enable_dispatch();
+  _Objects_Release( &ptimer->Object );
   return 0;
 }
diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c
index f8690eb..f90e5cf 100644
--- a/cpukit/posix/src/timerdelete.c
+++ b/cpukit/posix/src/timerdelete.c
@@ -54,7 +54,7 @@ int timer_delete(
       ptimer->state = POSIX_TIMER_STATE_FREE;
       (void) _Watchdog_Remove( &ptimer->Timer );
       _POSIX_Timer_Free( ptimer );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &ptimer->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c
index 23a4e6f..84b4f56 100644
--- a/cpukit/posix/src/timergetoverrun.c
+++ b/cpukit/posix/src/timergetoverrun.c
@@ -40,7 +40,7 @@ int timer_getoverrun(
     case OBJECTS_LOCAL:
       overrun = ptimer->overrun;
       ptimer->overrun = 0;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &ptimer->Object );
       return overrun;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c
index 7b9de53..5ad7ed7 100644
--- a/cpukit/posix/src/timergettime.c
+++ b/cpukit/posix/src/timergettime.c
@@ -68,7 +68,7 @@ int timer_gettime(
 
       value->it_interval  = ptimer->timer_data.it_interval;
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &ptimer->Object );
       return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
index 7bdcad8..879dcb7 100644
--- a/cpukit/posix/src/timersettime.c
+++ b/cpukit/posix/src/timersettime.c
@@ -95,7 +95,7 @@ int timer_settime(
          /* Indicates that the timer is created and stopped */
          ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
          /* Returns with success */
-        _Thread_Enable_dispatch();
+        _Objects_Release( &ptimer->Object );
         return 0;
        }
 
@@ -112,7 +112,7 @@ int timer_settime(
          ptimer
        );
        if ( !activated ) {
-         _Thread_Enable_dispatch();
+         _Objects_Release( &ptimer->Object );
          return 0;
        }
 
@@ -127,7 +127,7 @@ int timer_settime(
        /* Indicate that the time is running */
        ptimer->state = POSIX_TIMER_STATE_CREATE_RUN;
        _TOD_Get( &ptimer->time );
-       _Thread_Enable_dispatch();
+      _Objects_Release( &ptimer->Object );
        return 0;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/barrierdelete.c b/cpukit/rtems/src/barrierdelete.c
index a73846d..7d4a641 100644
--- a/cpukit/rtems/src/barrierdelete.c
+++ b/cpukit/rtems/src/barrierdelete.c
@@ -47,7 +47,7 @@ rtems_status_code rtems_barrier_delete(
 
       _Barrier_Free( the_barrier );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_barrier->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/barrierrelease.c b/cpukit/rtems/src/barrierrelease.c
index 550d82a..dc41348 100644
--- a/cpukit/rtems/src/barrierrelease.c
+++ b/cpukit/rtems/src/barrierrelease.c
@@ -56,7 +56,7 @@ rtems_status_code rtems_barrier_release(
 
     case OBJECTS_LOCAL:
       *released = _CORE_barrier_Release( &the_barrier->Barrier, id, NULL );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_barrier->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index 05b592e..d2d2ec9 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -44,7 +44,7 @@ rtems_status_code rtems_barrier_wait(
         timeout,
         NULL
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_barrier->Object );
       return _Barrier_Translate_core_barrier_return_code(
                 _Thread_Executing->Wait.return_code );
 
diff --git a/cpukit/rtems/src/dpmemdelete.c b/cpukit/rtems/src/dpmemdelete.c
index 4f78035..6eb8ef1 100644
--- a/cpukit/rtems/src/dpmemdelete.c
+++ b/cpukit/rtems/src/dpmemdelete.c
@@ -40,7 +40,7 @@ rtems_status_code rtems_port_delete(
     case OBJECTS_LOCAL:
       _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
       _Dual_ported_memory_Free( the_port );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_port->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/dpmemexternal2internal.c b/cpukit/rtems/src/dpmemexternal2internal.c
index f5248fe..0fa9be8 100644
--- a/cpukit/rtems/src/dpmemexternal2internal.c
+++ b/cpukit/rtems/src/dpmemexternal2internal.c
@@ -49,7 +49,7 @@ rtems_status_code rtems_port_external_to_internal(
       else
         *internal = _Addresses_Add_offset( the_port->internal_base,
                                            ending );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_port->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/dpmeminternal2external.c b/cpukit/rtems/src/dpmeminternal2external.c
index a6c8d83..adbd0ea 100644
--- a/cpukit/rtems/src/dpmeminternal2external.c
+++ b/cpukit/rtems/src/dpmeminternal2external.c
@@ -50,7 +50,7 @@ rtems_status_code rtems_port_internal_to_external(
       else
         *external = _Addresses_Add_offset( the_port->external_base,
                                            ending );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_port->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/eventsend.c b/cpukit/rtems/src/eventsend.c
index a16382c..997e609 100644
--- a/cpukit/rtems/src/eventsend.c
+++ b/cpukit/rtems/src/eventsend.c
@@ -42,7 +42,7 @@ rtems_status_code rtems_event_send(
         &_Event_Sync_state,
         STATES_WAITING_FOR_EVENT
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &thread->Object );
       sc = RTEMS_SUCCESSFUL;
       break;
 #ifdef RTEMS_MULTIPROCESSING
diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c
index 4e595de..2c19c33 100644
--- a/cpukit/rtems/src/eventtimeout.c
+++ b/cpukit/rtems/src/eventtimeout.c
@@ -58,7 +58,7 @@ void _Event_Timeout(
          */
         if ( !the_thread->Wait.count ) {
           _ISR_Enable( level );
-          _Thread_Unnest_dispatch();
+          _Objects_Release_without_thread_dispatch( &the_thread->Object );
           return;
         }
 
@@ -71,7 +71,7 @@ void _Event_Timeout(
         the_thread->Wait.return_code = RTEMS_TIMEOUT;
       _ISR_Enable( level );
       _Thread_Unblock( the_thread );
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_thread->Object );
       break;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqbroadcast.c b/cpukit/rtems/src/msgqbroadcast.c
index a1c2a9f..a771232 100644
--- a/cpukit/rtems/src/msgqbroadcast.c
+++ b/cpukit/rtems/src/msgqbroadcast.c
@@ -70,7 +70,7 @@ rtems_status_code rtems_message_queue_broadcast(
                       count
                     );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
       return
         _Message_queue_Translate_core_message_queue_return_code( core_status );
 
diff --git a/cpukit/rtems/src/msgqdelete.c b/cpukit/rtems/src/msgqdelete.c
index 72fd6a0..81ef0f3 100644
--- a/cpukit/rtems/src/msgqdelete.c
+++ b/cpukit/rtems/src/msgqdelete.c
@@ -77,7 +77,7 @@ rtems_status_code rtems_message_queue_delete(
         );
       }
 #endif
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqflush.c b/cpukit/rtems/src/msgqflush.c
index a14e96d..1221033 100644
--- a/cpukit/rtems/src/msgqflush.c
+++ b/cpukit/rtems/src/msgqflush.c
@@ -69,7 +69,7 @@ rtems_status_code rtems_message_queue_flush(
 
     case OBJECTS_LOCAL:
       *count = _CORE_message_queue_Flush( &the_message_queue->message_queue );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqgetnumberpending.c b/cpukit/rtems/src/msgqgetnumberpending.c
index 0139144..f50488a 100644
--- a/cpukit/rtems/src/msgqgetnumberpending.c
+++ b/cpukit/rtems/src/msgqgetnumberpending.c
@@ -67,7 +67,7 @@ rtems_status_code rtems_message_queue_get_number_pending(
 
     case OBJECTS_LOCAL:
       *count = the_message_queue->message_queue.number_of_pending_messages;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/msgqreceive.c b/cpukit/rtems/src/msgqreceive.c
index 6be06ad..8e47c02 100644
--- a/cpukit/rtems/src/msgqreceive.c
+++ b/cpukit/rtems/src/msgqreceive.c
@@ -71,7 +71,7 @@ rtems_status_code rtems_message_queue_receive(
         wait,
         timeout
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
       return _Message_queue_Translate_core_message_queue_return_code(
         _Thread_Executing->Wait.return_code
       );
diff --git a/cpukit/rtems/src/msgqsend.c b/cpukit/rtems/src/msgqsend.c
index 764859d..4e490c9 100644
--- a/cpukit/rtems/src/msgqsend.c
+++ b/cpukit/rtems/src/msgqsend.c
@@ -86,7 +86,7 @@ rtems_status_code rtems_message_queue_send(
         0        /* no timeout */
       );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
 
       /*
        *  Since this API does not allow for blocking sends, we can directly
diff --git a/cpukit/rtems/src/msgqurgent.c b/cpukit/rtems/src/msgqurgent.c
index fd749fa..4953237 100644
--- a/cpukit/rtems/src/msgqurgent.c
+++ b/cpukit/rtems/src/msgqurgent.c
@@ -68,7 +68,7 @@ rtems_status_code rtems_message_queue_urgent(
         false,   /* sender does not block */
         0        /* no timeout */
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_message_queue->Object );
 
       /*
        *  Since this API does not allow for blocking sends, we can directly
diff --git a/cpukit/rtems/src/partdelete.c b/cpukit/rtems/src/partdelete.c
index 6aeee4e..535e0a8 100644
--- a/cpukit/rtems/src/partdelete.c
+++ b/cpukit/rtems/src/partdelete.c
@@ -58,10 +58,10 @@ rtems_status_code rtems_partition_delete(
         }
 #endif
 
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_partition->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_partition->Object );
       return RTEMS_RESOURCE_IN_USE;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/partgetbuffer.c b/cpukit/rtems/src/partgetbuffer.c
index f281fe4..5135a68 100644
--- a/cpukit/rtems/src/partgetbuffer.c
+++ b/cpukit/rtems/src/partgetbuffer.c
@@ -46,11 +46,11 @@ rtems_status_code rtems_partition_get_buffer(
       the_buffer = _Partition_Allocate_buffer( the_partition );
       if ( the_buffer ) {
         the_partition->number_of_used_blocks += 1;
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_partition->Object );
         *buffer = the_buffer;
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_partition->Object );
       return RTEMS_UNSATISFIED;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/partreturnbuffer.c b/cpukit/rtems/src/partreturnbuffer.c
index bec3c16..0a1fbc8 100644
--- a/cpukit/rtems/src/partreturnbuffer.c
+++ b/cpukit/rtems/src/partreturnbuffer.c
@@ -53,10 +53,10 @@ rtems_status_code rtems_partition_return_buffer(
       if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
         _Partition_Free_buffer( the_partition, buffer );
         the_partition->number_of_used_blocks -= 1;
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_partition->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_partition->Object );
       return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c
index af6a972..eb15d37 100644
--- a/cpukit/rtems/src/ratemoncancel.c
+++ b/cpukit/rtems/src/ratemoncancel.c
@@ -38,13 +38,13 @@ rtems_status_code rtems_rate_monotonic_cancel(
 
     case OBJECTS_LOCAL:
       if ( !_Thread_Is_executing( the_period->owner ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return RTEMS_NOT_OWNER_OF_RESOURCE;
       }
       (void) _Watchdog_Remove( &the_period->Timer );
       the_period->state = RATE_MONOTONIC_INACTIVE;
       _Scheduler_Release_job(the_period->owner, 0);
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_period->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c
index 15498ea..8463b43 100644
--- a/cpukit/rtems/src/ratemondelete.c
+++ b/cpukit/rtems/src/ratemondelete.c
@@ -42,7 +42,7 @@ rtems_status_code rtems_rate_monotonic_delete(
       (void) _Watchdog_Remove( &the_period->Timer );
       the_period->state = RATE_MONOTONIC_INACTIVE;
       _Rate_monotonic_Free( the_period );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_period->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemongetstatistics.c b/cpukit/rtems/src/ratemongetstatistics.c
index 801cd94..3cc2eff 100644
--- a/cpukit/rtems/src/ratemongetstatistics.c
+++ b/cpukit/rtems/src/ratemongetstatistics.c
@@ -63,7 +63,7 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
         dst->total_wall_time = src->total_wall_time;
       #endif
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_period->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c
index 5d0d584..c59924d 100644
--- a/cpukit/rtems/src/ratemongetstatus.c
+++ b/cpukit/rtems/src/ratemongetstatus.c
@@ -73,7 +73,7 @@ rtems_status_code rtems_rate_monotonic_get_status(
             the_period, &since_last_period, &executed
           );
         if (!valid_status) {
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_period->Object );
           return RTEMS_NOT_DEFINED;
         }
 
@@ -90,7 +90,7 @@ rtems_status_code rtems_rate_monotonic_get_status(
         #endif
       }
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_period->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c
index 91f457b..861baf8 100644
--- a/cpukit/rtems/src/ratemonperiod.c
+++ b/cpukit/rtems/src/ratemonperiod.c
@@ -245,7 +245,7 @@ rtems_status_code rtems_rate_monotonic_period(
   switch ( location ) {
     case OBJECTS_LOCAL:
       if ( !_Thread_Is_executing( the_period->owner ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return RTEMS_NOT_OWNER_OF_RESOURCE;
       }
 
@@ -263,7 +263,7 @@ rtems_status_code rtems_rate_monotonic_period(
             return_value = RTEMS_SUCCESSFUL;
             break;
         }
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return( return_value );
       }
 
@@ -287,7 +287,7 @@ rtems_status_code rtems_rate_monotonic_period(
         );
 
         _Watchdog_Insert_ticks( &the_period->Timer, length );
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return RTEMS_SUCCESSFUL;
       }
 
@@ -326,7 +326,7 @@ rtems_status_code rtems_rate_monotonic_period(
         if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING )
           _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
 
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return RTEMS_SUCCESSFUL;
       }
 
@@ -343,7 +343,7 @@ rtems_status_code rtems_rate_monotonic_period(
 
         _Watchdog_Insert_ticks( &the_period->Timer, length );
         _Scheduler_Release_job(the_period->owner, the_period->next_length);
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_period->Object );
         return RTEMS_TIMEOUT;
       }
 
diff --git a/cpukit/rtems/src/ratemonresetstatistics.c b/cpukit/rtems/src/ratemonresetstatistics.c
index a9d3934..3351cc3 100644
--- a/cpukit/rtems/src/ratemonresetstatistics.c
+++ b/cpukit/rtems/src/ratemonresetstatistics.c
@@ -53,7 +53,7 @@ rtems_status_code rtems_rate_monotonic_reset_statistics(
 
     case OBJECTS_LOCAL:
       _Rate_monotonic_Reset_statistics( the_period );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_period->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c
index 183e62f..0d495be 100644
--- a/cpukit/rtems/src/ratemontimeout.c
+++ b/cpukit/rtems/src/ratemontimeout.c
@@ -59,7 +59,7 @@ void _Rate_monotonic_Timeout(
         _Watchdog_Insert_ticks( &the_period->Timer, the_period->next_length );
       } else
         the_period->state = RATE_MONOTONIC_EXPIRED;
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_period->Object );
       break;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/regiongetsegment.c b/cpukit/rtems/src/regiongetsegment.c
index 1f38e5c..9055531 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -79,6 +79,7 @@ rtems_status_code rtems_region_get_segment(
              *  dispatching disabled critical section.  We have to do this
              *  because this thread is going to block.
              */
+            /* FIXME: Lock order reversal */
             _Thread_Disable_dispatch();
             _RTEMS_Unlock_allocator();
 
@@ -91,7 +92,7 @@ rtems_status_code rtems_region_get_segment(
 
             _Thread_queue_Enqueue( &the_region->Wait_queue, timeout );
 
-            _Thread_Enable_dispatch();
+            _Objects_Release( &the_region->Object );
 
             return (rtems_status_code) executing->Wait.return_code;
           }
diff --git a/cpukit/rtems/src/rtemsobjectsetname.c b/cpukit/rtems/src/rtemsobjectsetname.c
index 2f61231..178d6ca 100644
--- a/cpukit/rtems/src/rtemsobjectsetname.c
+++ b/cpukit/rtems/src/rtemsobjectsetname.c
@@ -54,7 +54,7 @@ rtems_status_code rtems_object_set_name(
 
     case OBJECTS_LOCAL:
       _Objects_Set_name( information, the_object, name );
-      _Thread_Enable_dispatch();
+      _Objects_Release( the_object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c
index 57e00db..1f9d4c4 100644
--- a/cpukit/rtems/src/semdelete.c
+++ b/cpukit/rtems/src/semdelete.c
@@ -59,7 +59,7 @@ rtems_status_code rtems_semaphore_delete(
         if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) &&
              !_Attributes_Is_simple_binary_semaphore(
                  the_semaphore->attribute_set ) ) {
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_semaphore->Object );
           return RTEMS_RESOURCE_IN_USE;
         }
         _CORE_mutex_Flush(
@@ -92,7 +92,7 @@ rtems_status_code rtems_semaphore_delete(
         );
       }
 #endif
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c
index f6cfa7f..037fe63 100644
--- a/cpukit/rtems/src/semflush.c
+++ b/cpukit/rtems/src/semflush.c
@@ -68,7 +68,7 @@ rtems_status_code rtems_semaphore_flush(
           CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT
         );
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_semaphore->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
index 6600966..0e3ad25 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -91,7 +91,7 @@ rtems_status_code rtems_semaphore_release(
           id,
           MUTEX_MP_SUPPORT
         );
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_semaphore->Object );
         return _Semaphore_Translate_core_mutex_return_code( mutex_status );
       } else {
         semaphore_status = _CORE_semaphore_Surrender(
@@ -99,7 +99,7 @@ rtems_status_code rtems_semaphore_release(
           id,
           MUTEX_MP_SUPPORT
         );
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_semaphore->Object );
         return
           _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
       }
diff --git a/cpukit/rtems/src/signalsend.c b/cpukit/rtems/src/signalsend.c
index 5696007..0ae1c0f 100644
--- a/cpukit/rtems/src/signalsend.c
+++ b/cpukit/rtems/src/signalsend.c
@@ -56,10 +56,10 @@ rtems_status_code rtems_signal_send(
         } else {
           _ASR_Post_signals( signal_set, &asr->signals_pending );
         }
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_NOT_DEFINED;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/systemeventsend.c b/cpukit/rtems/src/systemeventsend.c
index 8a0efc6..e6bfa31 100644
--- a/cpukit/rtems/src/systemeventsend.c
+++ b/cpukit/rtems/src/systemeventsend.c
@@ -48,7 +48,7 @@ rtems_status_code rtems_event_system_send(
         &_System_event_Sync_state,
         STATES_WAITING_FOR_SYSTEM_EVENT
       );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &thread->Object );
       sc = RTEMS_SUCCESSFUL;
       break;
 #ifdef RTEMS_MULTIPROCESSING
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index 6ab5798..b866ac3 100644
--- a/cpukit/rtems/src/taskdelete.c
+++ b/cpukit/rtems/src/taskdelete.c
@@ -54,11 +54,11 @@ rtems_status_code rtems_task_delete(
       the_information = _Objects_Get_information_id( the_thread->Object.id );
 
       #if defined(RTEMS_DEBUG)
-	if ( !the_information ) {
-	  _Thread_Enable_dispatch();
-	  return RTEMS_INVALID_ID;
-	  /* This should never happen if _Thread_Get() works right */
-	}
+        if ( !the_information ) {
+          _Objects_Release( &the_thread->Object );
+          return RTEMS_INVALID_ID;
+          /* This should never happen if _Thread_Get() works right */
+        }
       #endif
 
       #if defined(RTEMS_MULTIPROCESSING)
@@ -76,8 +76,9 @@ rtems_status_code rtems_task_delete(
 
       _RTEMS_tasks_Free( the_thread );
 
+      /* FIXME: Lock order reversal */
       _RTEMS_Unlock_allocator();
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskgetnote.c b/cpukit/rtems/src/taskgetnote.c
index 65b2aa2..0c82f23 100644
--- a/cpukit/rtems/src/taskgetnote.c
+++ b/cpukit/rtems/src/taskgetnote.c
@@ -75,7 +75,7 @@ rtems_status_code rtems_task_get_note(
     case OBJECTS_LOCAL:
       api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
       *note = api->Notepads[ notepad ];
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskissuspended.c b/cpukit/rtems/src/taskissuspended.c
index 6a62dd5..4648b58 100644
--- a/cpukit/rtems/src/taskissuspended.c
+++ b/cpukit/rtems/src/taskissuspended.c
@@ -60,10 +60,10 @@ rtems_status_code rtems_task_is_suspended(
 
     case OBJECTS_LOCAL:
       if ( !_States_Is_suspended( the_thread->current_state ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_ALREADY_SUSPENDED;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskrestart.c b/cpukit/rtems/src/taskrestart.c
index 75fcbb3..aa7102e 100644
--- a/cpukit/rtems/src/taskrestart.c
+++ b/cpukit/rtems/src/taskrestart.c
@@ -46,10 +46,10 @@ rtems_status_code rtems_task_restart(
 
     case OBJECTS_LOCAL:
       if ( _Thread_Restart( the_thread, NULL, argument ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_INCORRECT_STATE;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskresume.c b/cpukit/rtems/src/taskresume.c
index a3a8f73..6686d8e 100644
--- a/cpukit/rtems/src/taskresume.c
+++ b/cpukit/rtems/src/taskresume.c
@@ -46,10 +46,10 @@ rtems_status_code rtems_task_resume(
     case OBJECTS_LOCAL:
       if ( _States_Is_suspended( the_thread->current_state ) ) {
         _Thread_Resume( the_thread );
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_INCORRECT_STATE;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/tasksetnote.c b/cpukit/rtems/src/tasksetnote.c
index b08198d..7a42b5d 100644
--- a/cpukit/rtems/src/tasksetnote.c
+++ b/cpukit/rtems/src/tasksetnote.c
@@ -72,7 +72,7 @@ rtems_status_code rtems_task_set_note(
     case OBJECTS_LOCAL:
       api = the_thread->API_Extensions[ THREAD_API_RTEMS ];
       api->Notepads[ notepad ] = note;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c
index 5eebe68..dd871bb 100644
--- a/cpukit/rtems/src/tasksetpriority.c
+++ b/cpukit/rtems/src/tasksetpriority.c
@@ -61,7 +61,7 @@ rtems_status_code rtems_task_set_priority(
              the_thread->current_priority > new_priority )
           _Thread_Change_priority( the_thread, new_priority, false );
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskstart.c b/cpukit/rtems/src/taskstart.c
index 4a168bf..62a7495 100644
--- a/cpukit/rtems/src/taskstart.c
+++ b/cpukit/rtems/src/taskstart.c
@@ -68,10 +68,10 @@ rtems_status_code rtems_task_start(
     case OBJECTS_LOCAL:
       if ( _Thread_Start(
              the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_INCORRECT_STATE;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/tasksuspend.c b/cpukit/rtems/src/tasksuspend.c
index 8128100..d873f79 100644
--- a/cpukit/rtems/src/tasksuspend.c
+++ b/cpukit/rtems/src/tasksuspend.c
@@ -46,10 +46,10 @@ rtems_status_code rtems_task_suspend(
     case OBJECTS_LOCAL:
       if ( !_States_Is_suspended( the_thread->current_state ) ) {
         _Thread_Suspend( the_thread );
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_SUCCESSFUL;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_ALREADY_SUSPENDED;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskvariableadd.c b/cpukit/rtems/src/taskvariableadd.c
index 9a0bc3d..55e5c2a 100644
--- a/cpukit/rtems/src/taskvariableadd.c
+++ b/cpukit/rtems/src/taskvariableadd.c
@@ -46,7 +46,7 @@ rtems_status_code rtems_task_variable_add(
       while (tvp) {
         if (tvp->ptr == ptr) {
           tvp->dtor = dtor;
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_thread->Object );
           return RTEMS_SUCCESSFUL;
         }
         tvp = (rtems_task_variable_t *)tvp->next;
@@ -58,7 +58,7 @@ rtems_status_code rtems_task_variable_add(
       new = (rtems_task_variable_t *)
          _Workspace_Allocate(sizeof(rtems_task_variable_t));
       if (new == NULL) {
-        _Thread_Enable_dispatch();
+        _Objects_Release( &the_thread->Object );
         return RTEMS_NO_MEMORY;
       }
       new->gval = *ptr;
@@ -67,7 +67,7 @@ rtems_status_code rtems_task_variable_add(
 
       new->next = (struct rtems_task_variable_tt *)the_thread->task_variables;
       the_thread->task_variables = new;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskvariabledelete.c b/cpukit/rtems/src/taskvariabledelete.c
index cb13b98..aeca78b 100644
--- a/cpukit/rtems/src/taskvariabledelete.c
+++ b/cpukit/rtems/src/taskvariabledelete.c
@@ -49,13 +49,13 @@ rtems_status_code rtems_task_variable_delete(
             the_thread->task_variables = (rtems_task_variable_t *)tvp->next;
 
           _RTEMS_Tasks_Invoke_task_variable_dtor( the_thread, tvp );
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_thread->Object );
           return RTEMS_SUCCESSFUL;
         }
         prev = tvp;
         tvp = (rtems_task_variable_t *)tvp->next;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/taskvariableget.c b/cpukit/rtems/src/taskvariableget.c
index d2074b2..6e140b2 100644
--- a/cpukit/rtems/src/taskvariableget.c
+++ b/cpukit/rtems/src/taskvariableget.c
@@ -59,12 +59,12 @@ rtems_status_code rtems_task_variable_get(
 	   * saved) value if `tid' is the current task?
 	   */
           *result = tvp->tval;
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_thread->Object );
           return RTEMS_SUCCESSFUL;
         }
         tvp = (rtems_task_variable_t *)tvp->next;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_thread->Object );
       return RTEMS_INVALID_ADDRESS;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timercancel.c b/cpukit/rtems/src/timercancel.c
index 3faf0ed..69b2221 100644
--- a/cpukit/rtems/src/timercancel.c
+++ b/cpukit/rtems/src/timercancel.c
@@ -49,7 +49,7 @@ rtems_status_code rtems_timer_cancel(
     case OBJECTS_LOCAL:
       if ( !_Timer_Is_dormant_class( the_timer->the_class ) )
         (void) _Watchdog_Remove( &the_timer->Ticker );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerdelete.c b/cpukit/rtems/src/timerdelete.c
index f259280..934e8df 100644
--- a/cpukit/rtems/src/timerdelete.c
+++ b/cpukit/rtems/src/timerdelete.c
@@ -41,7 +41,7 @@ rtems_status_code rtems_timer_delete(
       _Objects_Close( &_Timer_Information, &the_timer->Object );
       (void) _Watchdog_Remove( &the_timer->Ticker );
       _Timer_Free( the_timer );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerfireafter.c b/cpukit/rtems/src/timerfireafter.c
index 267c1cf..f405086 100644
--- a/cpukit/rtems/src/timerfireafter.c
+++ b/cpukit/rtems/src/timerfireafter.c
@@ -59,7 +59,7 @@ rtems_status_code rtems_timer_fire_after(
 
         if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
           _ISR_Enable( level );
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_timer->Object );
           return RTEMS_SUCCESSFUL;
         }
 
@@ -74,7 +74,7 @@ rtems_status_code rtems_timer_fire_after(
 
 
       _Watchdog_Insert_ticks( &the_timer->Ticker, ticks );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerfirewhen.c b/cpukit/rtems/src/timerfirewhen.c
index 487471f..acc237f 100644
--- a/cpukit/rtems/src/timerfirewhen.c
+++ b/cpukit/rtems/src/timerfirewhen.c
@@ -62,7 +62,7 @@ rtems_status_code rtems_timer_fire_when(
          &the_timer->Ticker,
          seconds - _TOD_Seconds_since_epoch()
        );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timergetinfo.c b/cpukit/rtems/src/timergetinfo.c
index c6088a1..f3f098f 100644
--- a/cpukit/rtems/src/timergetinfo.c
+++ b/cpukit/rtems/src/timergetinfo.c
@@ -46,7 +46,7 @@ rtems_status_code rtems_timer_get_information(
       the_info->initial    = the_timer->Ticker.initial;
       the_info->start_time = the_timer->Ticker.start_time;
       the_info->stop_time  = the_timer->Ticker.stop_time;
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerreset.c b/cpukit/rtems/src/timerreset.c
index 0e80521..4ad9378 100644
--- a/cpukit/rtems/src/timerreset.c
+++ b/cpukit/rtems/src/timerreset.c
@@ -66,7 +66,7 @@ rtems_status_code rtems_timer_reset(
          */
         #if defined(RTEMS_DEBUG)
           if ( !timer_server ) {
-            _Thread_Enable_dispatch();
+            _Objects_Release( &the_timer->Object );
             return RTEMS_INCORRECT_STATE;
           }
         #endif
@@ -80,7 +80,7 @@ rtems_status_code rtems_timer_reset(
          */
         status = RTEMS_NOT_DEFINED;
       }
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return status;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerserverfireafter.c b/cpukit/rtems/src/timerserverfireafter.c
index ee8dc8f..dd7318e 100644
--- a/cpukit/rtems/src/timerserverfireafter.c
+++ b/cpukit/rtems/src/timerserverfireafter.c
@@ -63,7 +63,7 @@ rtems_status_code rtems_timer_server_fire_after(
 
         if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
           _ISR_Enable( level );
-          _Thread_Enable_dispatch();
+          _Objects_Release( &the_timer->Object );
           return RTEMS_SUCCESSFUL;
         }
 
@@ -79,7 +79,7 @@ rtems_status_code rtems_timer_server_fire_after(
 
       (*timer_server->schedule_operation)( timer_server, the_timer );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/rtems/src/timerserverfirewhen.c b/cpukit/rtems/src/timerserverfirewhen.c
index 11a1e15..c4cfdbd 100644
--- a/cpukit/rtems/src/timerserverfirewhen.c
+++ b/cpukit/rtems/src/timerserverfirewhen.c
@@ -83,7 +83,7 @@ rtems_status_code rtems_timer_server_fire_when(
 
       (*timer_server->schedule_operation)( timer_server, the_timer );
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_timer->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/sapi/src/extensiondelete.c b/cpukit/sapi/src/extensiondelete.c
index 0a60f74..cff9495 100644
--- a/cpukit/sapi/src/extensiondelete.c
+++ b/cpukit/sapi/src/extensiondelete.c
@@ -37,7 +37,7 @@ rtems_status_code rtems_extension_delete(
       _User_extensions_Remove_set( &the_extension->Extension );
       _Objects_Close( &_Extension_Information, &the_extension->Object );
       _Extension_Free( the_extension );
-      _Thread_Enable_dispatch();
+      _Objects_Release( &the_extension->Object );
       return RTEMS_SUCCESSFUL;
 
 #if defined(RTEMS_MULTIPROCESSING)
diff --git a/cpukit/score/inline/rtems/score/object.inl b/cpukit/score/inline/rtems/score/object.inl
index 26ae085..feb6d22 100644
--- a/cpukit/score/inline/rtems/score/object.inl
+++ b/cpukit/score/inline/rtems/score/object.inl
@@ -377,6 +377,35 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum )
 #endif
 
 /**
+ * @brief Releases an object obtained with _Objects_Get().
+ *
+ * This function decrements the thread dispatch disable level.  The
+ * _Thread_Dispatch() is called if the level reaches zero.
+ */
+RTEMS_INLINE_ROUTINE void _Objects_Release(
+  Objects_Control *the_object
+)
+{
+  (void) the_object;
+  _Thread_Enable_dispatch();
+}
+
+/**
+ * @brief Releases an object obtained with _Objects_Get().
+ *
+ * This function decrements the thread dispatch disable level.  The
+ * _Thread_Dispatch() is not called if the level reaches zero, thus a thread
+ * dispatch will not take place immediately on the current processor.
+ */
+RTEMS_INLINE_ROUTINE void _Objects_Release_without_thread_dispatch(
+  Objects_Control *the_object
+)
+{
+  (void) the_object;
+  _Thread_Unnest_dispatch();
+}
+
+/**
  * @brief Releases an object obtained with _Objects_Get_isr_disable().
  */
 RTEMS_INLINE_ROUTINE void _Objects_Release_for_get_isr_disable(
diff --git a/cpukit/score/src/corerwlocktimeout.c b/cpukit/score/src/corerwlocktimeout.c
index 73e93f8..9e97048 100644
--- a/cpukit/score/src/corerwlocktimeout.c
+++ b/cpukit/score/src/corerwlocktimeout.c
@@ -39,7 +39,7 @@ void _CORE_RWLock_Timeout(
       break;
     case OBJECTS_LOCAL:
       _Thread_queue_Process_timeout( the_thread );
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_thread->Object );
       break;
   }
 }
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 98b99c7..157817c 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -267,7 +267,7 @@ Thread_Control *_MPCI_Process_response (
     case OBJECTS_LOCAL:
       _Thread_queue_Extract( &_MPCI_Remote_blocked_threads, the_thread );
       the_thread->Wait.return_code = the_packet->return_code;
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_thread->Object );
     break;
   }
 
diff --git a/cpukit/score/src/objectgetnameasstring.c b/cpukit/score/src/objectgetnameasstring.c
index d818f72..95d8180 100644
--- a/cpukit/score/src/objectgetnameasstring.c
+++ b/cpukit/score/src/objectgetnameasstring.c
@@ -95,7 +95,7 @@ char *_Objects_Get_name_as_string(
       }
       *d = '\0';
 
-      _Thread_Enable_dispatch();
+      _Objects_Release( the_object );
       return name;
   }
   return NULL;                  /* unreachable path */
diff --git a/cpukit/score/src/objectidtoname.c b/cpukit/score/src/objectidtoname.c
index 1c0d926..17556d6 100644
--- a/cpukit/score/src/objectidtoname.c
+++ b/cpukit/score/src/objectidtoname.c
@@ -63,6 +63,6 @@ Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
     return OBJECTS_INVALID_ID;
 
   *name = the_object->name;
-  _Thread_Enable_dispatch();
+  _Objects_Release( the_object );
   return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
 }
diff --git a/cpukit/score/src/schedulercbsattachthread.c b/cpukit/score/src/schedulercbsattachthread.c
index 5a9ba04..0bd7db9 100644
--- a/cpukit/score/src/schedulercbsattachthread.c
+++ b/cpukit/score/src/schedulercbsattachthread.c
@@ -32,24 +32,10 @@ int _Scheduler_CBS_Attach_thread (
 {
   Objects_Locations location;
   Thread_Control *the_thread;
-  Scheduler_CBS_Per_thread *sched_info;
 
   if ( server_id >= _Scheduler_CBS_Maximum_servers )
     return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
 
-  the_thread = _Thread_Get(task_id, &location);
-  /* The routine _Thread_Get may disable dispatch and not enable again. */
-  if ( the_thread )
-    _Thread_Enable_dispatch();
-  if ( !the_thread )
-    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
-
-  sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
-
-  /* Thread is already attached to a server. */
-  if ( sched_info->cbs_server )
-    return SCHEDULER_CBS_ERROR_FULL;
-
   /* Server is not valid. */
   if ( !_Scheduler_CBS_Server_list[server_id] )
     return SCHEDULER_CBS_ERROR_NOSERVER;
@@ -58,12 +44,30 @@ int _Scheduler_CBS_Attach_thread (
   if ( _Scheduler_CBS_Server_list[server_id]->task_id != -1 )
     return SCHEDULER_CBS_ERROR_FULL;
 
-  _Scheduler_CBS_Server_list[server_id]->task_id = task_id;
-  sched_info->cbs_server = (void *) _Scheduler_CBS_Server_list[server_id];
+  the_thread = _Thread_Get(task_id, &location);
+  /* The routine _Thread_Get may disable dispatch and not enable again. */
+  if ( the_thread ) {
+    Scheduler_CBS_Per_thread *sched_info;
+
+    sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
+
+    /* Thread is already attached to a server. */
+    if ( sched_info->cbs_server ) {
+      _Objects_Release( &the_thread->Object );
+      return SCHEDULER_CBS_ERROR_FULL;
+    }
 
-  the_thread->budget_callout   = _Scheduler_CBS_Budget_callout;
-  the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
-  the_thread->is_preemptible   = true;
+    _Scheduler_CBS_Server_list[server_id]->task_id = task_id;
+    sched_info->cbs_server = (void *) _Scheduler_CBS_Server_list[server_id];
+
+    the_thread->budget_callout   = _Scheduler_CBS_Budget_callout;
+    the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
+    the_thread->is_preemptible   = true;
+
+    _Objects_Release( &the_thread->Object );
+  } else {
+    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
+  }
 
   return SCHEDULER_CBS_OK;
 }
diff --git a/cpukit/score/src/schedulercbsdetachthread.c b/cpukit/score/src/schedulercbsdetachthread.c
index f4ce602..95bb6fa 100644
--- a/cpukit/score/src/schedulercbsdetachthread.c
+++ b/cpukit/score/src/schedulercbsdetachthread.c
@@ -34,16 +34,8 @@ int _Scheduler_CBS_Detach_thread (
   Thread_Control *the_thread;
   Scheduler_CBS_Per_thread *sched_info;
 
-  the_thread = _Thread_Get(task_id, &location);
-  /* The routine _Thread_Get may disable dispatch and not enable again. */
-  if ( the_thread ) {
-    _Thread_Enable_dispatch();
-  }
-
   if ( server_id >= _Scheduler_CBS_Maximum_servers )
     return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
-  if ( !the_thread )
-    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
   /* Server is not valid. */
   if ( !_Scheduler_CBS_Server_list[server_id] )
     return SCHEDULER_CBS_ERROR_NOSERVER;
@@ -51,13 +43,21 @@ int _Scheduler_CBS_Detach_thread (
   if ( _Scheduler_CBS_Server_list[server_id]->task_id != task_id )
     return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
 
-  _Scheduler_CBS_Server_list[server_id]->task_id = -1;
-  sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
-  sched_info->cbs_server = NULL;
+  the_thread = _Thread_Get(task_id, &location);
+  /* The routine _Thread_Get may disable dispatch and not enable again. */
+  if ( the_thread ) {
+    _Scheduler_CBS_Server_list[server_id]->task_id = -1;
+    sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
+    sched_info->cbs_server = NULL;
 
-  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
-  the_thread->budget_callout   = the_thread->Start.budget_callout;
-  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
+    the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
+    the_thread->budget_callout   = the_thread->Start.budget_callout;
+    the_thread->is_preemptible   = the_thread->Start.is_preemptible;
+
+    _Objects_Release( &the_thread->Object );
+  } else {
+    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
+  }
 
   return SCHEDULER_CBS_OK;
 }
diff --git a/cpukit/score/src/schedulercbsgetexecutiontime.c b/cpukit/score/src/schedulercbsgetexecutiontime.c
index 005cd32..1faac51 100644
--- a/cpukit/score/src/schedulercbsgetexecutiontime.c
+++ b/cpukit/score/src/schedulercbsgetexecutiontime.c
@@ -49,9 +49,9 @@ int _Scheduler_CBS_Get_execution_time (
                );
   /* The routine _Thread_Get may disable dispatch and not enable again. */
   if ( the_thread ) {
-    _Thread_Enable_dispatch();
     *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget -
       the_thread->cpu_time_budget;
+    _Objects_Release( &the_thread->Object );
   }
   else {
     *exec_time = _Scheduler_CBS_Server_list[server_id]->parameters.budget;
diff --git a/cpukit/score/src/schedulercbsgetremainingbudget.c b/cpukit/score/src/schedulercbsgetremainingbudget.c
index 892c371..77be7cb 100644
--- a/cpukit/score/src/schedulercbsgetremainingbudget.c
+++ b/cpukit/score/src/schedulercbsgetremainingbudget.c
@@ -47,8 +47,8 @@ int _Scheduler_CBS_Get_remaining_budget (
                );
   /* The routine _Thread_Get may disable dispatch and not enable again. */
   if ( the_thread ) {
-    _Thread_Enable_dispatch();
     *remaining_budget = the_thread->cpu_time_budget;
+    _Objects_Release( &the_thread->Object );
   }
   else {
     *remaining_budget = 0;
diff --git a/cpukit/score/src/threaddelayended.c b/cpukit/score/src/threaddelayended.c
index 2750fb7..e1e07df 100644
--- a/cpukit/score/src/threaddelayended.c
+++ b/cpukit/score/src/threaddelayended.c
@@ -54,7 +54,7 @@ void _Thread_Delay_ended(
           | STATES_WAITING_FOR_TIME
           | STATES_INTERRUPTIBLE_BY_SIGNAL
       );
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_thread->Object );
       break;
   }
 }
diff --git a/cpukit/score/src/threadqtimeout.c b/cpukit/score/src/threadqtimeout.c
index 4792666..667a046 100644
--- a/cpukit/score/src/threadqtimeout.c
+++ b/cpukit/score/src/threadqtimeout.c
@@ -45,7 +45,7 @@ void _Thread_queue_Timeout(
       break;
     case OBJECTS_LOCAL:
       _Thread_queue_Process_timeout( the_thread );
-      _Thread_Unnest_dispatch();
+      _Objects_Release_without_thread_dispatch( &the_thread->Object );
       break;
   }
 }
-- 
1.7.7




More information about the devel mailing list