38 #define THREAD_JOIN_TQ_OPERATIONS &_Thread_queue_Operations_priority 40 static void _Thread_Life_action_handler(
56 static void _Thread_Raise_real_priority(
67 if ( priority < the_thread->Real_priority.priority ) {
101 static void _Thread_Wake_up_joining_threads(
Thread_Control *the_thread )
111 THREAD_JOIN_TQ_OPERATIONS,
112 _Thread_Join_flush_filter,
117 static void _Thread_Add_to_zombie_chain(
Thread_Control *the_thread )
122 zombies = &_Thread_Zombies;
130 #if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) 131 if ( _Thread_Owns_resources( the_thread ) ) {
150 _Thread_Add_to_zombie_chain( the_thread );
152 _Thread_Wake_up_joining_threads( the_thread );
172 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) 173 #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) 174 if ( _Thread_Is_allocated_fp( the_thread ) )
175 _Thread_Deallocate_fp();
181 the_thread->
Wait.spare_heads
190 #if defined(RTEMS_SMP) 193 _SMP_lock_Stats_destroy( &the_thread->Potpourri_stats );
197 _Context_Destroy( the_thread, &the_thread->
Registers );
201 static void _Thread_Wait_for_execution_stop(
Thread_Control *the_thread )
203 #if defined(RTEMS_SMP) 226 while ( the_thread != NULL ) {
229 _Thread_Wait_for_execution_stop( the_thread );
230 _Thread_Free( the_thread );
269 _Thread_Life_action_handler
303 void _Thread_Life_action_handler(
314 previous_life_state = executing->
Life.
state;
315 executing->
Life.
state = previous_life_state | THREAD_LIFE_PROTECTED;
330 cpu_self = _Thread_Wait_for_join( executing, cpu_self );
331 _Thread_Make_zombie( executing );
352 _Thread_Change_life_locked(
354 THREAD_LIFE_PROTECTED | THREAD_LIFE_RESTARTING,
368 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) 369 if ( executing->fp_context != NULL ) {
378 static void _Thread_Add_life_change_request(
Thread_Control *the_thread )
380 uint32_t pending_requests;
382 _Assert( _Thread_State_is_owner( the_thread ) );
387 if ( pending_requests == 0 ) {
392 static void _Thread_Remove_life_change_request(
Thread_Control *the_thread )
395 uint32_t pending_requests;
402 if ( pending_requests == 1 ) {
419 static void _Thread_Finalize_life_change(
426 _Thread_Raise_real_priority( the_thread, priority );
427 _Thread_Remove_life_change_request( the_thread );
437 _Assert( the_thread != executing );
438 _Assert( _Thread_State_is_owner( the_thread ) );
445 THREAD_JOIN_TQ_OPERATIONS,
451 static void _Thread_Set_exit_value(
470 _Assert( the_thread != executing );
474 _Thread_Set_exit_value( the_thread, exit_value );
475 previous = _Thread_Change_life_locked(
478 THREAD_LIFE_TERMINATING,
487 _Thread_Make_zombie( the_thread );
489 _Thread_Add_life_change_request( the_thread );
492 _Thread_Finalize_life_change( the_thread, priority );
494 _Thread_Add_life_change_request( the_thread );
498 _Thread_Raise_real_priority( the_thread, priority );
499 _Thread_Remove_life_change_request( the_thread );
505 static void _Thread_Close_enqueue_callout(
524 context->cancel = the_thread;
527 _Thread_Close_enqueue_callout
558 _Thread_Set_exit_value( executing, exit_value );
559 _Thread_Change_life_locked(
563 THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED
585 previous = _Thread_Change_life_locked(
588 THREAD_LIFE_RESTARTING,
595 _Thread_Add_life_change_request( the_thread );
598 _Thread_Finalize_life_change(
633 _Thread_Change_life_locked(
636 THREAD_LIFE_RESTARTING,
637 THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED
671 previous = _Thread_Change_life_locked( executing, clear,
set, ignore );
683 THREAD_LIFE_PROTECTED,
684 state & THREAD_LIFE_PROTECTED,
void _Thread_Load_environment(Thread_Control *the_thread)
Initializes enviroment for a thread.
static void _User_extensions_Thread_terminate(Thread_Control *executing)
Terminates the executing thread.
#define ISR_LOCK_INITIALIZER(_name)
Initializer for static initialization of ISR locks.
Thread_Life_state state
The current thread life state.
Thread_CPU_budget_algorithm_callout budget_callout
#define _ISR_lock_Destroy(_lock)
Destroys an ISR lock.
#define _Context_Restore_fp(_fp)
Restore floating point context area.
void _Thread_Close(Thread_Control *the_thread, Thread_Control *executing, Thread_Close_context *context)
Closes the thread.
The watchdog is inactive.
uint64_t Priority_Control
The thread priority control.
#define STATES_WAITING_FOR_JOIN
Thread_Life_state
Thread life states.
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
static __inline__ bool _Thread_Is_life_change_allowed(Thread_Life_state life_state)
Checks if the thread life state allos life change.
Thread_Wait_information Wait
static void _User_extensions_Thread_restart(Thread_Control *restarted)
Restarts a thread.
Thread queue context for the thread queue methods.
void _Thread_Dispatch_direct(Per_CPU_Control *cpu_self)
Directly do a thread dispatch.
Thread entry information.
#define STATES_LOCALLY_BLOCKED
void _Thread_Kill_zombies(void)
Kills all zombie threads in the system.
static __inline__ void _Thread_State_acquire_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the lock context in a critical section.
static __inline__ const Scheduler_Control * _Thread_Scheduler_get_home(const Thread_Control *the_thread)
Gets the home scheduler of the thread.
uint32_t pending_life_change_requests
The count of pending life change requests.
Inlined Routines in the Watchdog Handler.
static __inline__ bool _Thread_Is_executing_on_a_processor(const Thread_Control *the_thread)
Checks if the thread executes currently on some processor in the system.
Thread_Life_state _Thread_Change_life(Thread_Life_state clear, Thread_Life_state set, Thread_Life_state ignore)
Changes the currently executing thread to a new state with the sets.
Thread_Start_information Start
static __inline__ Watchdog_State _Watchdog_Get_state(const Watchdog_Control *the_watchdog)
Gets the state of the watchdog.
static __inline__ bool _Thread_Is_life_restarting(Thread_Life_state life_state)
Checks if the thread life state is restarting.
static __inline__ void _Thread_Add_post_switch_action(Thread_Control *the_thread, Thread_Action *action, Thread_Action_handler handler)
Adds a post switch action to the thread with the given handler.
void _Thread_Exit(Thread_Control *executing, Thread_Life_state set, void *exit_value)
Exits the currently executing thread.
#define CHAIN_INITIALIZER_EMPTY(name)
Chain initializer for an empty chain with designator name.
void _Thread_queue_Acquire(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Inlined Routines Associated with the Manipulation of the Scheduler.
Objects_Information * _Objects_Get_information_id(Objects_Id id)
Gets information of an object from an ID.
static __inline__ void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
#define STATES_LIFE_IS_CHANGING
static void _User_extensions_Thread_delete(Thread_Control *deleted)
Deletes a thread.
Thread_Keys_information Keys
The POSIX Keys information.
#define _Context_Restart_self(_the_context)
Restart currently executing thread.
Thread_Scheduler_control Scheduler
Scheduler related control.
User Extension Handler API.
static __inline__ void _Thread_State_release(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the lock context and enables interrupts.
static __inline__ void _Thread_queue_Context_set_enqueue_callout(Thread_queue_Context *queue_context, Thread_queue_Enqueue_callout enqueue_callout)
Sets the enqueue callout in the thread queue context.
Inlined Routines from the Stack Handler.
Information for the Assert Handler.
void _Thread_Join(Thread_Control *the_thread, States_Control waiting_for_join, Thread_Control *executing, Thread_queue_Context *queue_context)
Joins the currently executing thread with the given thread to wait for.
Thread_queue_Queue Queue
The actual thread queue.
static __inline__ void _Thread_queue_Context_set_thread_state(Thread_queue_Context *queue_context, States_Control thread_state)
Sets the thread state for the thread to enqueue in the thread queue context.
static __inline__ void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
static __inline__ Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
Thread_CPU_budget_algorithms budget_algorithm
static __inline__ bool _States_Is_dormant(States_Control the_states)
Checks if DORMANT state is set.
static void _User_extensions_Destroy_iterators(Thread_Control *the_thread)
Destroys all user extension iterators of a thread.
size_t _Thread_queue_Flush_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_queue_Flush_filter filter, Thread_queue_Context *queue_context)
Unblocks all threads enqueued on the thread queue.
static __inline__ void _Thread_Timer_remove(Thread_Control *the_thread)
Remove the watchdog timer from the thread.
Thread_Life_state _Thread_Set_life_protection(Thread_Life_state state)
Set the thread to life protected.
States_Control _Thread_Set_state_locked(Thread_Control *the_thread, States_Control state)
Sets the specified thread state without locking the lock context.
static __inline__ Scheduler_Node * _Thread_Scheduler_get_home_node(const Thread_Control *the_thread)
Gets the scheduler's home node.
static __inline__ void _Thread_Wait_acquire(Thread_Control *the_thread, Thread_queue_Context *queue_context)
Acquires the thread wait default lock and disables interrupts.
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Constants and Structures Associated with the Manipulation of Objects.
void _Thread_queue_Extract_with_proxy(Thread_Control *the_thread)
Extracts the_thread from the_thread_queue.
States_Control current_state
static __inline__ Priority_Control _Thread_Get_priority(const Thread_Control *the_thread)
Returns the priority of the thread.
static __inline__ void _Thread_Wait_acquire_default(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the thread wait default lock and disables interrupts.
void _Thread_Priority_update(Thread_queue_Context *queue_context)
Updates the priority of all threads in the set.
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
States_Control _Thread_Set_state(Thread_Control *the_thread, States_Control state)
Sets the specified thread state.
static __inline__ void _Thread_queue_Context_clear_priority_updates(Thread_queue_Context *queue_context)
Clears the priority update count of the thread queue context.
void * exit_value
The thread exit value.
static __inline__ bool _Thread_Is_joinable(const Thread_Control *the_thread)
Checks if the thread is joinable.
#define _ISR_lock_ISR_disable_and_acquire(_lock, _context)
Acquires an ISR lock.
void _Thread_Restart_self(Thread_Control *executing, const Thread_Entry_information *entry, ISR_lock_Context *lock_context)
Restarts the currently executing thread.
static void __inline__ _Freechain_Push(Freechain_Control *freechain, void *node)
Pushes a node back to the freechain.
static __inline__ Per_CPU_Control * _Thread_Dispatch_disable(void)
Disables thread dispatching.
States_Control _Thread_Clear_state_locked(Thread_Control *the_thread, States_Control state)
Clears the specified thread state without locking the lock context.
System State Handler API.
Thread_queue_Control Join_queue
Thread queue for thread join operations and multi-purpose lock.
static __inline__ bool _Thread_queue_Is_empty(const Thread_queue_Queue *queue)
Checks if the thread queue queue is empty.
void _Internal_error(Internal_errors_Core_list core_error) RTEMS_NO_RETURN
Terminates the system with an INTERNAL_ERROR_CORE fatal source and the specified core error code...
Inlined Routines from the Thread Handler.
static __inline__ Thread_Control * _Thread_State_acquire_for_executing(ISR_lock_Context *lock_context)
Disables interrupts and acquires the lock context for the currently executing thread.
static __inline__ bool _Thread_Is_life_terminating(Thread_Life_state life_state)
Checks if the thread life state is terminating.
Local ISR lock context for acquire and release pairs.
static __inline__ void _Thread_Wait_release(Thread_Control *the_thread, Thread_queue_Context *queue_context)
Releases the thread wait lock and restores the previous interrupt status.
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
static __inline__ void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
static __inline__ bool _Thread_Is_life_changing(Thread_Life_state life_state)
Checks if the thread life state is life changing.
Thread_Action Action
Thread life action used to react upon thread restart and delete requests.
static __inline__ void _Thread_Priority_change(Thread_Control *the_thread, Priority_Node *priority_node, Priority_Control new_priority, bool prepend_it, Thread_queue_Context *queue_context)
Changes the thread priority value of the specified thread priority node in the corresponding thread p...
void _Thread_Cancel(Thread_Control *the_thread, Thread_Control *executing, void *exit_value)
Cancels the thread.
ISR_lock_Control Lock
Lock to protect the scheduler node change requests.
void _Thread_queue_Enqueue(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Blocks the thread and places it on the thread queue.
#define STATES_WAITING_FOR_JOIN_AT_EXIT
Context_Control Registers
static __inline__ void _Thread_State_acquire(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Disables interrupts and acquires the lock_context.
Thread_Life_control Life
Thread life-cycle control.
Priority_Node Real_priority
The base priority of this thread in its home scheduler instance.
void _Objects_Close(const Objects_Information *information, Objects_Control *the_object)
Closes object.
static __inline__ void _Scheduler_Node_destroy(const Scheduler_Control *scheduler, Scheduler_Node *node)
Destroys a scheduler node.
Information Related to the RAM Workspace.
static __inline__ void _Thread_Wait_release_default(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the thread wait default lock and restores the previous interrupt status. ...
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
#define RTEMS_UNREACHABLE()
Tells the compiler that this program point is unreachable.
Thread_Timer_information Timer
static __inline__ Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
bool _Thread_Restart_other(Thread_Control *the_thread, const Thread_Entry_information *entry, ISR_lock_Context *lock_context)
Restarts the thread.
static __inline__ void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.