static Per_CPU_Control *_Thread_Wait_for_join( Thread_Control *executing, Per_CPU_Control *cpu_self ) { #if defined(RTEMS_POSIX_API) ISR_lock_Context lock_context; _Thread_State_acquire( executing, &lock_context ); if ( _Thread_Is_joinable( executing ) && _Thread_queue_Is_empty( &executing->Join_queue.Queue ) ) { _Thread_Set_state_locked( executing, STATES_WAITING_FOR_JOIN_AT_EXIT ); _Thread_State_release( executing, &lock_context ); _Thread_Dispatch_enable( cpu_self ); /* Let other threads run */ cpu_self = _Thread_Dispatch_disable(); } else { _Thread_State_release( executing, &lock_context ); } #endif return cpu_self; }
int pthread_rwlock_destroy( pthread_rwlock_t *rwlock ) { POSIX_RWLock_Control *the_rwlock; ISR_lock_Context lock_context; _Objects_Allocator_lock(); the_rwlock = _POSIX_RWLock_Get( rwlock, &lock_context ); if ( the_rwlock == NULL ) { _Objects_Allocator_unlock(); return EINVAL; } _CORE_RWLock_Acquire_critical( &the_rwlock->RWLock, &lock_context ); /* * If there is at least one thread waiting, then do not delete it. */ if ( !_Thread_queue_Is_empty( &the_rwlock->RWLock.Wait_queue.Queue ) ) { _CORE_RWLock_Release( &the_rwlock->RWLock, &lock_context ); _Objects_Allocator_unlock(); return EBUSY; } /* * POSIX doesn't require behavior when it is locked. */ _Objects_Close( &_POSIX_RWLock_Information, &the_rwlock->Object ); _CORE_RWLock_Release( &the_rwlock->RWLock, &lock_context ); _POSIX_RWLock_Free( the_rwlock ); _Objects_Allocator_unlock(); return 0; }