From 2d2352bab92c51c2fd857b9555242545bd08c95e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 5 Jun 2013 11:48:57 +0200 Subject: score: Add and use _Objects_Put() Add and use _Objects_Put_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 | 18 +++++----- 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, 253 insertions(+), 209 deletions(-) diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c index ba5e7b7e40..b8eed9b449 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; - - _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(); + Objects_Locations location; + Barrier_Control *the_barrier; + + the_barrier = _Barrier_Get(pipe->readBarrier, &location); + the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL; + _Objects_Put( &the_barrier->Object ); + + the_barrier = _Barrier_Get(pipe->writeBarrier, &location); + the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL; + _Objects_Put( &the_barrier->Object ); } #endif diff --git a/cpukit/posix/src/canceleval.c b/cpukit/posix/src/canceleval.c index 973d2a7db1..7e4ff02eaf 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_Put( &the_thread->Object ); } diff --git a/cpukit/posix/src/conddestroy.c b/cpukit/posix/src/conddestroy.c index 99f60569e2..157049c95b 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_Put( &the_cond->Object ); return EBUSY; } @@ -56,7 +56,7 @@ int pthread_cond_destroy( ); _POSIX_Condition_variables_Free( the_cond ); - _Thread_Enable_dispatch(); + _Objects_Put( &the_cond->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/condsignalsupp.c b/cpukit/posix/src/condsignalsupp.c index 36bb60ebb2..376c1a51c1 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_Put( &the_cond->Object ); return 0; diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c index 91bdc32a0c..53a0830ff7 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_Put_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_Put( &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_Put( &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_Put( &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_Put( &the_cond->Object ); status = ETIMEDOUT; } diff --git a/cpukit/posix/src/keydelete.c b/cpukit/posix/src/keydelete.c index 5ef6261148..8f96ca36fe 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_Put( &the_key->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c index debad830ae..0e8bbcdec8 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_Put( &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 b25e44ccbf..22eb8eb643 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_Put( &the_key->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/mqueueclose.c b/cpukit/posix/src/mqueueclose.c index 4f1bb41bd3..f4d866156e 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_Put( &the_mq_fd->Object ); return 0; } diff --git a/cpukit/posix/src/mqueuegetattr.c b/cpukit/posix/src/mqueuegetattr.c index 0f250f1c2d..f4244d0700 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_Put( &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 5387335c33..e2a53e9547 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_Put( &the_mq_fd->Object ); rtems_set_errno_and_return_minus_one( EBUSY ); } @@ -88,7 +88,7 @@ int mq_notify( } - _Thread_Enable_dispatch(); + _Objects_Put( &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 5cfce067c6..cf1698fc00 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_Put( &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_Put( &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_Put( &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 1f9bf63d5a..093c42599a 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_Put( &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_Put( &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 2fbcd95e3f..0e16f1fc55 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_Put( &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 f733ce714c..27ebde0b97 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_Put( &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_Put( &the_mutex->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/mutexgetprioceiling.c b/cpukit/posix/src/mutexgetprioceiling.c index 8355286ebc..450a9daeba 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_Put( &the_mutex->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c index 979e5b84b9..b955847e6e 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_Put( &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 920d6fae92..e50567d561 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_Put( &the_mutex->Object ); return 0; diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c index cfe8bdbeeb..3804ec6c7e 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_Put( &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 66f701452f..baf788e083 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_Put( &the_barrier->Object ); return EBUSY; } @@ -58,7 +58,7 @@ int pthread_barrier_destroy( _POSIX_Barrier_Free( the_barrier ); - _Thread_Enable_dispatch(); + _Objects_Put( &the_barrier->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c index e941bf5d7f..e55faa8fde 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_Put( &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 6c99abf128..329a297f08 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_Put( &the_rwlock->Object ); return EBUSY; } @@ -64,7 +64,7 @@ int pthread_rwlock_destroy( _POSIX_RWLock_Free( the_rwlock ); - _Thread_Enable_dispatch(); + _Objects_Put( &the_rwlock->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/prwlockrdlock.c b/cpukit/posix/src/prwlockrdlock.c index 24adcb451c..621a7f84a4 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_Put( &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 414fec3fd3..732ba2a129 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_Put( &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 84aa3a00ff..bd6232a49a 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_Put( &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 f58467743c..c6e2875bb5 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_Put( &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 6b51d17611..26eb3e16bd 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_Put( &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 d9c2f6fa75..67fca021cf 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_Put( &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 672772e6e3..8643be1f4d 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_Put( &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 f49fd47348..f7243540b6 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_Put( &the_spinlock->Object ); return EBUSY; } @@ -58,7 +58,7 @@ int pthread_spin_destroy( _POSIX_Spinlock_Free( the_spinlock ); - _Thread_Enable_dispatch(); + _Objects_Put( &the_spinlock->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c index 3d0aed903b..2f4bfffaa6 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_Put( &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 08ace6d9da..7f7c6c17e1 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_Put( &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 8f7c5b1e96..dc43d1d1c9 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_Put( &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 824537eb8c..52a42f6b37 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_Put( &the_thread->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/pthreadequal.c b/cpukit/posix/src/pthreadequal.c index 199cc8fb9a..9b2b0282ed 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_Put_without_thread_dispatch( &thread_2->Object ); + _Objects_Put( &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_Put( &thread_1->Object ); /* return status == 0 */ break; } diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c index 2e995c49bc..01bcf6fbde 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 d681f0479a..ee430715e8 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_Put( &the_thread->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c index 8304aa3685..cd8c40af18 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_Put( &the_thread->Object ); return EINVAL; } if ( _Thread_Is_executing( the_thread ) ) { - _Thread_Enable_dispatch(); + _Objects_Put( &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_Put( &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 e0f395070d..b9f4922fd7 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_Put( &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_Put( &the_thread->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c index 06216f49a1..5fcc816d86 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_Put( &the_thread->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c index 08a26ee16f..f3ce6003d1 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_Put( &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 a9521bdd6b..07f75367df 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_Put( &the_semaphore->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/semdestroy.c b/cpukit/posix/src/semdestroy.c index 14ba520fa3..cef340620a 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_Put( &the_semaphore->Object ); rtems_set_errno_and_return_minus_one( EINVAL ); } _POSIX_Semaphore_Delete( the_semaphore ); - _Thread_Enable_dispatch(); + _Objects_Put( &the_semaphore->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/semgetvalue.c b/cpukit/posix/src/semgetvalue.c index 8ea0bdad07..24527d16a1 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_Put( &the_semaphore->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/sempost.c b/cpukit/posix/src/sempost.c index 7ce367986f..79e5ec83ff 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_Put( &the_semaphore->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/timercreate.c b/cpukit/posix/src/timercreate.c index bd52f87fe9..a8690b6699 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_Put( &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_Put( &ptimer->Object ); return 0; } diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c index f8690eb2fc..e17d48b181 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_Put( &ptimer->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c index 23a4e6f3fe..0708db4f7d 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_Put( &ptimer->Object ); return overrun; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c index 7b9de539b6..a4b0f3ae58 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_Put( &ptimer->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c index 7bdcad8bad..678266ae3c 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_Put( &ptimer->Object ); return 0; } @@ -112,7 +112,7 @@ int timer_settime( ptimer ); if ( !activated ) { - _Thread_Enable_dispatch(); + _Objects_Put( &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_Put( &ptimer->Object ); return 0; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/rtems/src/barrierdelete.c b/cpukit/rtems/src/barrierdelete.c index a73846dc6e..db6f9288da 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_Put( &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 550d82a2dd..38aaa83cc3 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_Put( &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 05b592e65b..aae06c8694 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_Put( &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 4f78035346..6746e158b5 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_Put( &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 f5248fe946..010429dc6d 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_Put( &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 a6c8d833ae..7881d6b9a9 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_Put( &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 a16382c048..b72317c0cb 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_Put( &thread->Object ); sc = RTEMS_SUCCESSFUL; break; #ifdef RTEMS_MULTIPROCESSING diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c index 4e595dede6..9d244f0e9b 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_Put_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_Put_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 a1c2a9f417..c56ab1a335 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_Put( &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 72fd6a077e..557ab83475 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_Put( &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 a14e96dae0..90b0660bab 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_Put( &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 0139144623..27d7db09bc 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_Put( &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 6be06ad67c..3c9d0609c3 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_Put( &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 764859d745..54bb86e94a 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_Put( &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 fd749fabfc..7b157fbbc9 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_Put( &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 6aeee4e422..2248adc830 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_Put( &the_partition->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 f281fe4e65..393cab6cd3 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_Put( &the_partition->Object ); *buffer = the_buffer; return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 bec3c166c6..378b75578b 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_Put( &the_partition->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 af6a972a8e..4a2e49c9c1 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_Put( &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_Put( &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 15498ea833..35ee9c4ff6 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_Put( &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 801cd9410f..eca0ce8390 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_Put( &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 5d0d584063..bd97bd045e 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_Put( &the_period->Object ); return RTEMS_NOT_DEFINED; } @@ -90,7 +90,7 @@ rtems_status_code rtems_rate_monotonic_get_status( #endif } - _Thread_Enable_dispatch(); + _Objects_Put( &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 91f457bbb6..2018123e25 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_Put( &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_Put( &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_Put( &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_Put( &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_Put( &the_period->Object ); return RTEMS_TIMEOUT; } diff --git a/cpukit/rtems/src/ratemonresetstatistics.c b/cpukit/rtems/src/ratemonresetstatistics.c index a9d3934742..4269403b52 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_Put( &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 183e62fdcc..59461d1526 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_Put_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 1f38e5cbce..8d52ed031b 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_Put( &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 2f61231031..7e35225189 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_Put( the_object ); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c index 57e00db0e5..12eb37f51a 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_Put( &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_Put( &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 f6cfa7fa2c..bed91aa13f 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_Put( &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 66009667b7..a5da108736 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_Put( &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_Put( &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 5696007696..eb259303f4 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 8a0efc694b..3c3fe46616 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_Put( &thread->Object ); sc = RTEMS_SUCCESSFUL; break; #ifdef RTEMS_MULTIPROCESSING diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c index 6ab579821f..492f3e73f4 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_Put( &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_Put( &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 65b2aa21f9..9748a1d5da 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_Put( &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 6a62dd5b2a..842be740cd 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 75fcbb342e..dcffc0a0f3 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 a3a8f73571..2f59c04383 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 b08198db4b..eb5ed9e16b 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_Put( &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 5eebe686ae..29504815a0 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_Put( &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 4a168bf742..3700139da3 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 8128100c78..e6f99807e7 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 9a0bc3d43f..7e03b660ca 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_Put( &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_Put( &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_Put( &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 cb13b98d0a..02f2bf0113 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } prev = tvp; tvp = (rtems_task_variable_t *)tvp->next; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 d2074b274b..338e108389 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_Put( &the_thread->Object ); return RTEMS_SUCCESSFUL; } tvp = (rtems_task_variable_t *)tvp->next; } - _Thread_Enable_dispatch(); + _Objects_Put( &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 3faf0ed930..01f583d0b2 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_Put( &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 f25928054a..a9e4e3245b 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_Put( &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 267c1cfd98..2c34797126 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_Put( &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_Put( &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 487471ffc3..9bd786b5b3 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_Put( &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 c6088a1a66..c3b6ec6847 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_Put( &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 0e8052161f..23ebb46744 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_Put( &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_Put( &the_timer->Object ); return status; #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/rtems/src/timerserverfireafter.c b/cpukit/rtems/src/timerserverfireafter.c index ee8dc8f3da..27d52c2c00 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_Put( &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_Put( &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 11a1e15dc8..a27095fb48 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_Put( &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 0a60f741d9..7e4957eafc 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_Put( &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 54365fa8eb..bab5f984e3 100644 --- a/cpukit/score/inline/rtems/score/object.inl +++ b/cpukit/score/inline/rtems/score/object.inl @@ -376,6 +376,35 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum ) #endif +/** + * @brief Puts back 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_Put( + Objects_Control *the_object +) +{ + (void) the_object; + _Thread_Enable_dispatch(); +} + +/** + * @brief Puts back 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_Put_without_thread_dispatch( + Objects_Control *the_object +) +{ + (void) the_object; + _Thread_Unnest_dispatch(); +} + /** * @brief Puts back an object obtained with _Objects_Get_isr_disable(). */ diff --git a/cpukit/score/src/corerwlocktimeout.c b/cpukit/score/src/corerwlocktimeout.c index 73e93f8eb0..3b20364e10 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_Put_without_thread_dispatch( &the_thread->Object ); break; } } diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 98b99c7a7e..e3e7eb81f9 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_Put_without_thread_dispatch( &the_thread->Object ); break; } diff --git a/cpukit/score/src/objectgetnameasstring.c b/cpukit/score/src/objectgetnameasstring.c index d818f72396..ceb6c43b24 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_Put( the_object ); return name; } return NULL; /* unreachable path */ diff --git a/cpukit/score/src/objectidtoname.c b/cpukit/score/src/objectidtoname.c index 1c0d926838..d3f05e3df4 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_Put( the_object ); return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; } diff --git a/cpukit/score/src/schedulercbsattachthread.c b/cpukit/score/src/schedulercbsattachthread.c index 5a9ba04721..5192bc0779 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_Put( &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_Put( &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 f4ce6029cc..cbc37eb195 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_Put( &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 005cd325ad..e54cb44141 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_Put( &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 892c371d0f..2ab0941c9f 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_Put( &the_thread->Object ); } else { *remaining_budget = 0; diff --git a/cpukit/score/src/threaddelayended.c b/cpukit/score/src/threaddelayended.c index 2750fb7788..dc8ccb4248 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_Put_without_thread_dispatch( &the_thread->Object ); break; } } diff --git a/cpukit/score/src/threadqtimeout.c b/cpukit/score/src/threadqtimeout.c index 4792666cf8..c310551f9e 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_Put_without_thread_dispatch( &the_thread->Object ); break; } } -- cgit v1.2.3