rtems_status_code rtems_task_delete( rtems_id id ) { Thread_Control *the_thread; Objects_Locations location; bool previous_life_protection; previous_life_protection = _Thread_Set_life_protection( true ); the_thread = _Thread_Get( id, &location ); switch ( location ) { case OBJECTS_LOCAL: #if defined(RTEMS_MULTIPROCESSING) if ( the_thread->is_global ) { _Objects_MP_Close( &_RTEMS_tasks_Information.Objects, the_thread->Object.id ); _RTEMS_tasks_MP_Send_process_packet( RTEMS_TASKS_MP_ANNOUNCE_DELETE, the_thread->Object.id, 0 /* Not used */ ); } #endif _Thread_Close( the_thread, _Thread_Executing ); _Objects_Put( &the_thread->Object ); _Thread_Set_life_protection( previous_life_protection ); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: _Thread_Dispatch(); _Thread_Set_life_protection( previous_life_protection ); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif case OBJECTS_ERROR: break; } _Thread_Set_life_protection( previous_life_protection ); return RTEMS_INVALID_ID; }
void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) { bool previous_thread_life_protection; ISR_Level level; previous_thread_life_protection = _Thread_Set_life_protection( true ); #if defined(RTEMS_SMP) _Thread_Disable_dispatch(); #endif _ISR_Disable( level ); _CORE_mutex_Seize( &the_mutex->Mutex, _Thread_Executing, the_mutex->Object.id, true, 0, level ); if ( the_mutex->Mutex.nest_count == 1 ) { the_mutex->previous_thread_life_protection = previous_thread_life_protection; } #if defined(RTEMS_SMP) _Thread_Enable_dispatch(); #endif }
void _POSIX_Thread_Exit( Thread_Control *the_thread, void *value_ptr ) { Thread_Control *unblocked; POSIX_API_Control *api; bool previous_life_protection; api = the_thread->API_Extensions[ THREAD_API_POSIX ]; _Assert( _Debug_Is_thread_dispatching_allowed() ); previous_life_protection = _Thread_Set_life_protection( true ); _Thread_Disable_dispatch(); the_thread->Wait.return_argument = value_ptr; /* * Process join */ if ( api->detachstate == PTHREAD_CREATE_JOINABLE ) { unblocked = _Thread_queue_Dequeue( &api->Join_List ); if ( unblocked ) { do { *(void **)unblocked->Wait.return_argument = value_ptr; } while ( (unblocked = _Thread_queue_Dequeue( &api->Join_List )) ); } else { _Thread_Set_state( the_thread, STATES_WAITING_FOR_JOIN_AT_EXIT ); _Thread_Enable_dispatch(); /* now waiting for thread to arrive */ _Thread_Disable_dispatch(); } } /* * Now shut down the thread */ _Thread_Close( the_thread, _Thread_Executing ); _Thread_Enable_dispatch(); _Thread_Set_life_protection( previous_life_protection ); }
void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) { bool previous_thread_life_protection; ISR_lock_Context lock_context; previous_thread_life_protection = _Thread_Set_life_protection( true ); _ISR_lock_ISR_disable( &lock_context ); _CORE_mutex_Seize( &the_mutex->Mutex, _Thread_Executing, the_mutex->Object.id, true, 0, &lock_context ); if ( the_mutex->Mutex.nest_count == 1 ) { the_mutex->previous_thread_life_protection = previous_thread_life_protection; } }
void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) { Thread_Life_state previous_thread_life_state; Thread_queue_Context queue_context; previous_thread_life_state = _Thread_Set_life_protection( THREAD_LIFE_PROTECTED ); _Thread_queue_Context_initialize( &queue_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context ); _Thread_queue_Context_set_no_timeout( &queue_context ); _CORE_recursive_mutex_Seize( &the_mutex->Mutex, _Thread_Executing, true, _CORE_recursive_mutex_Seize_nested, &queue_context ); if ( the_mutex->Mutex.nest_level == 0 ) { the_mutex->previous_thread_life_state = previous_thread_life_state; } }