RTEMS 6.1-rc2
|
This group contains the Thread Handler implementation. More...
Modules | |
Thread Handler Multiprocessing (MP) Support | |
This group contains the implementation to support the Thread Handler in multiprocessing (MP) configurations. | |
Files | |
file | thread.h |
This header file provides interfaces of the Thread Handler which are used by the implementation and the Application Configuration. | |
file | threadcpubudget.h |
This header file provides interfaces used to implement the CPU budget management of threads. | |
file | threaddispatch.h |
This header file provides the interfaces of the Thread Handler related to thread dispatching. | |
file | threadidledata.h |
This header file provides data structures used by the implementation and the Application Configuration to define _Thread_Idle_stack_size and _Thread_Idle_body. | |
file | threadimpl.h |
This header file provides interfaces of the Thread Handler which are only used by the implementation. | |
file | iterateoverthreads.c |
This source file contains the implementation of rtems_iterate_over_all_threads(). | |
file | thread.c |
This source file contains static assertions related to the Thread Handler and the implementation of _Thread_Initialize_information() and _Thread_Handler_initialization(). | |
file | threadallocateunlimited.c |
This source file contains the implementation of _Thread_Extend_information(). | |
file | threadchangepriority.c |
This source file contains the implementation of _Thread_Priority_add(), _Thread_Priority_and_sticky_update(), _Thread_Priority_changed(), _Thread_Priority_perform_actions(), _Thread_Priority_remove(), _Thread_Priority_replace(), and _Thread_Priority_update(). | |
file | threadclearstate.c |
This source file contains the implementation of _Thread_Clear_state_locked() and _Thread_Clear_state(). | |
file | threadcreateidle.c |
This source file contains the implementation of _Thread_Create_idle(). | |
file | threaddispatch.c |
This source file contains the definition of _Thread_Allocated_fp and _User_extensions_Switches_list and the implementation of _Thread_Dispatch_direct(), _Thread_Dispatch_enable(), and _Thread_Do_dispatch(). | |
file | threadentryadaptoridle.c |
This source file contains the implementation of _Thread_Entry_adaptor_idle(). | |
file | threadentryadaptornumeric.c |
This source file contains the implementation of _Thread_Entry_adaptor_numeric(). | |
file | threadentryadaptorpointer.c |
This source file contains the implementation of _Thread_Entry_adaptor_pointer(). | |
file | threadexhausttimeslice.c |
This source file contains the definition of _Thread_CPU_budget_exhaust_timeslice and the implementation of _Thread_CPU_budget_do_nothing(). | |
file | threadget.c |
This source file contains the implementation of _Thread_Get(). | |
file | threadgetcputimeused.c |
This source file contains the implementation of _Thread_Get_CPU_time_used() and _Thread_Get_CPU_time_used_locked(). | |
file | threadgetcputimeusedafterreset.c |
This source file contains the implementation of _Thread_Get_CPU_time_used_after_last_reset(). | |
file | threadhandler.c |
This source file contains the definition of _Thread_Global_constructor and the implementation of _Thread_Handler(). | |
file | threadidledefault.c |
This source file contains the default definition of _Thread_Idle_body. | |
file | threadinitialize.c |
This source file contains the implementation of _Thread_Initialize(). | |
file | threaditerate.c |
This source file contains the implementation of _Thread_Iterate(). | |
file | threadloadenv.c |
This source file contains the implementation of _Thread_Load_environment(). | |
file | threadname.c |
This source file contains the implementation of _Thread_Set_name() and _Thread_Get_name(). | |
file | threadplaindispatch.c |
This source file contains the implementation of _Thread_Dispatch(). | |
file | threadresettimeslice.c |
This source file contains the definition of _Thread_CPU_budget_reset_timeslice and the implementation of _Thread_CPU_budget_consume_and_yield() and _Thread_CPU_budget_set_to_ticks_per_timeslice(). | |
file | threadrestart.c |
This source file contains the implementation of _Thread_Cancel(), _Thread_Change_life(), _Thread_Close(), _Thread_Exit(), _Thread_Join(), _Thread_Kill_zombies(), _Thread_Restart(), and _Thread_Set_life_protection(). | |
file | threadscheduler.c |
This source file contains the implementation of _Thread_Scheduler_process_requests(). | |
file | threadselfid.c |
This source file contains the implementation of _Thread_Self_id(). | |
file | threadsetstate.c |
This source file contains the implementation of _Thread_Set_state_locked() and _Thread_Set_state. | |
file | threadstart.c |
This source file contains the implementation of _Thread_Start(). | |
file | threadstartmultitasking.c |
This source file contains the implementation of _Thread_Start_multitasking(). | |
file | threadtimeout.c |
This source file contains the implementation of _Thread_Continue() and _Thread_Timeout(). | |
file | threadunpin.c |
This source file contains the implementation of _Thread_Do_unpin(). | |
file | threadwaitgetid.c |
This source file contains the implementation of _Thread_Wait_get_id(). | |
file | threadyield.c |
This source file contains the implementation of _Thread_Yield(). | |
Data Structures | |
struct | Thread_Entry_idle |
Data for idle thread entry. More... | |
struct | Thread_Entry_numeric |
Data for thread entry with one numeric argument and no return value. More... | |
struct | Thread_Entry_pointer |
Data for thread entry with one pointer argument and a pointer return value. More... | |
struct | Thread_Entry_information |
Thread entry information. More... | |
struct | Thread_CPU_budget_operations |
This structure contains operations which manage the CPU budget of a thread. More... | |
struct | Thread_CPU_budget_control |
This structure is used to control the CPU budget of a thread. More... | |
struct | Thread_Start_information |
struct | Thread_Scheduler_control |
Thread scheduler control. More... | |
union | Thread_Wait_information_Object_argument_type |
Union type to hold a pointer to an immutable or a mutable object. More... | |
struct | Thread_Wait_information |
Information required to manage a thread while it is blocked. More... | |
struct | Thread_Timer_information |
Information required to manage a thread timer. More... | |
struct | Thread_Proxy_control |
struct | Thread_Action |
Thread action. More... | |
struct | Thread_Keys_information |
Per-thread information for POSIX Keys. More... | |
struct | Thread_Action_control |
Control block to manage thread actions. More... | |
struct | Thread_Life_control |
Thread life control. More... | |
struct | Thread_Capture_control |
struct | _Thread_Control |
struct | Thread_Control_add_on |
Thread control add-on. More... | |
struct | Thread_Information |
The thread object information. More... | |
struct | Thread_Zombie_registry |
The thread zombie registry is used to register threads in the STATES_ZOMBIE state. More... | |
struct | Thread_Configuration |
The configuration of a new thread to initialize. More... | |
Macros | |
#define | THREAD_API_FIRST THREAD_API_RTEMS |
#define | THREAD_API_LAST THREAD_API_POSIX |
#define | THREAD_LIFE_PROTECTED 0x1U |
Indicates that the thread life is protected. | |
#define | THREAD_LIFE_RESTARTING 0x2U |
Indicates that thread is restarting. | |
#define | THREAD_LIFE_TERMINATING 0x4U |
Indicates that thread is terminating. | |
#define | THREAD_LIFE_CHANGE_DEFERRED 0x8U |
Indicates that thread life changes are deferred. | |
#define | THREAD_LIFE_DETACHED 0x10U |
Indicates that thread is detached. | |
#define | THREAD_DEFAULT_MAXIMUM_NAME_SIZE 16 |
The default maximum size of a thread name in characters (including the terminating '\0' character). | |
#define | _Thread_queue_Heads_size sizeof(Thread_queue_Heads) |
Size of the thread queue heads of a particular application. | |
#define | THREAD_INFORMATION_DEFINE_ZERO(name, api, cls) |
#define | THREAD_INFORMATION_DEFINE(name, api, cls, max) |
#define | RTEMS_SCORE_ROBUST_THREAD_DISPATCH |
Enables a robust thread dispatch. | |
#define | THREAD_WAIT_STATE_MASK 0xffU |
Mask to get the thread wait state flags. | |
#define | THREAD_WAIT_STATE_READY 0x0U |
Indicates that the thread does not wait on something. | |
#define | THREAD_WAIT_STATE_INTEND_TO_BLOCK 0x1U |
Indicates that the thread begins with the blocking operation. | |
#define | THREAD_WAIT_STATE_BLOCKED 0x2U |
Indicates that the thread completed the blocking operation. | |
#define | THREAD_WAIT_CLASS_MASK 0xff00U |
Mask to get the thread wait class flags. | |
#define | THREAD_WAIT_CLASS_EVENT 0x100U |
Indicates that the thread waits for an event. | |
#define | THREAD_WAIT_CLASS_SYSTEM_EVENT 0x200U |
Indicates that the thread waits for a system event. | |
#define | THREAD_WAIT_CLASS_OBJECT 0x400U |
Indicates that the thread waits for an object. | |
#define | THREAD_WAIT_CLASS_PERIOD 0x800U |
Indicates that the thread waits for a period. | |
Typedefs | |
typedef CPU_Uint32ptr | Thread_Entry_numeric_type |
Type of the numeric argument of a thread entry function with at least one numeric argument. | |
typedef unsigned int | Thread_Wait_flags |
This type is able to contain several flags used to control the wait class and state of a thread. | |
typedef struct Thread_Action | Thread_Action |
typedef void(* | Thread_Action_handler) (Thread_Control *the_thread, Thread_Action *action, ISR_lock_Context *lock_context) |
This type defines the prototype of thread action handlers. | |
typedef unsigned int | Thread_Life_state |
This type represents the thread life state. | |
typedef void(* | rtems_per_thread_routine) (Thread_Control *) |
typedef struct Thread_Configured_control | Thread_Configured_control |
The configured thread control block. | |
typedef Thread_queue_Heads | Thread_queue_Configured_heads |
The configured thread queue heads. | |
typedef void *(* | Thread_Idle_body) (uintptr_t) |
The idle thread body type. | |
typedef bool(* | Thread_Visitor) (Thread_Control *the_thread, void *arg) |
Enumerations | |
enum | Thread_APIs { THREAD_API_RTEMS , THREAD_API_POSIX } |
enum | Thread_Cancel_state { THREAD_CANCEL_DONE , THREAD_CANCEL_IN_PROGRESS } |
Indicates the resulting state of _Thread_Cancel(). More... | |
Functions | |
void | rtems_iterate_over_all_threads (rtems_per_thread_routine routine) RTEMS_DEPRECATED |
Deprecated, use rtems_task_iterate() instead. | |
Objects_Control * | _Thread_Allocate_unlimited (Objects_Information *information) |
Return an inactive thread object or NULL. | |
void | _Thread_CPU_budget_do_nothing (Thread_Control *the_thread) |
Does nothing. | |
void | _Thread_CPU_budget_set_to_ticks_per_timeslice (Thread_Control *the_thread) |
Sets the available CPU budget of the thread to the configured clock ticks per timeslice. | |
void | _Thread_CPU_budget_consume_and_yield (Thread_Control *the_thread) |
Consumes one time quantum of the available CPU budget of the thread and yields the thread if the available CPU budget is fully consumed. | |
void | _Thread_Dispatch (void) |
Performs a thread dispatch if necessary. | |
void | _Thread_Dispatch_direct (Per_CPU_Control *cpu_self) |
Directly do a thread dispatch. | |
RTEMS_NO_RETURN void | _Thread_Dispatch_direct_no_return (Per_CPU_Control *cpu_self) |
Directly do a thread dispatch and do not return. | |
void | _Thread_Do_dispatch (Per_CPU_Control *cpu_self, ISR_Level level) |
Performs a thread dispatch on the current processor. | |
void | _Thread_Dispatch_enable (Per_CPU_Control *cpu_self) |
Enables thread dispatching. | |
void | _Thread_Iterate (Thread_Visitor visitor, void *arg) |
Calls the visitor with all threads and the given argument until it is done. | |
void | _Thread_Initialize_information (Thread_Information *information) |
Initializes the thread information. | |
void | _Thread_Handler_initialization (void) |
Initializes thread handler. | |
void | _Thread_Create_idle (void) |
Creates idle thread. | |
RTEMS_NO_RETURN void | _Thread_Start_multitasking (void) |
Starts thread multitasking. | |
Status_Control | _Thread_Initialize (Thread_Information *information, Thread_Control *the_thread, const Thread_Configuration *config) |
Initializes thread. | |
void | _Thread_Free (Thread_Information *information, Thread_Control *the_thread) |
Frees the thread. | |
Status_Control | _Thread_Start (Thread_Control *the_thread, const Thread_Entry_information *entry, ISR_lock_Context *lock_context) |
Starts the specified thread. | |
Status_Control | _Thread_Restart (Thread_Control *the_thread, const Thread_Entry_information *entry, ISR_lock_Context *lock_context) |
Restarts the thread. | |
void | _Thread_Yield (Thread_Control *executing) |
Yields the currently executing thread. | |
Thread_Life_state | _Thread_Change_life (Thread_Life_state life_states_to_clear, Thread_Life_state life_states_to_set, Thread_Life_state ignored_life_states) |
Changes the life of currently executing thread. | |
Thread_Life_state | _Thread_Set_life_protection (Thread_Life_state state) |
Set the thread to life protected. | |
void | _Thread_Kill_zombies (void) |
Kills all zombie threads in the system. | |
RTEMS_NO_RETURN void | _Thread_Exit (void *exit_value, Thread_Life_state life_states_to_set) |
Exits the currently executing thread. | |
Status_Control | _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 thread. | |
Thread_Cancel_state | _Thread_Cancel (Thread_Control *the_thread, Thread_Control *executing, Thread_Life_state life_states_to_clear) |
Cancels the thread. | |
Status_Control | _Thread_Close (Thread_Control *the_thread, Thread_Control *executing, Thread_queue_Context *queue_context) |
Closes the thread. | |
States_Control | _Thread_Clear_state_locked (Thread_Control *the_thread, States_Control state) |
Clears the specified thread state without locking the lock context. | |
States_Control | _Thread_Clear_state (Thread_Control *the_thread, States_Control state) |
Clears the specified thread state. | |
States_Control | _Thread_Set_state_locked (Thread_Control *the_thread, States_Control state) |
Sets the specified thread state without locking the lock context. | |
States_Control | _Thread_Set_state (Thread_Control *the_thread, States_Control state) |
Sets the specified thread state. | |
void | _Thread_Load_environment (Thread_Control *the_thread) |
Initializes enviroment for a thread. | |
void | _Thread_Entry_adaptor_idle (Thread_Control *executing) |
Calls the start kinds idle entry of the thread. | |
void | _Thread_Entry_adaptor_numeric (Thread_Control *executing) |
Calls the start kinds numeric entry of the thread. | |
void | _Thread_Entry_adaptor_pointer (Thread_Control *executing) |
Calls the start kinds pointer entry of the thread. | |
void | _Thread_Handler (void) |
Wrapper function for all threads. | |
void | _Thread_Priority_perform_actions (Thread_Control *start_of_path, Thread_queue_Context *queue_context) |
Checks if the thread is owner of the lock of the join queue. | |
void | _Thread_Priority_add (Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context) |
Adds the specified thread priority node to the corresponding thread priority aggregation. | |
void | _Thread_Priority_remove (Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context) |
Removes the specified thread priority node from the corresponding thread priority aggregation. | |
void | _Thread_Priority_changed (Thread_Control *the_thread, Priority_Node *priority_node, Priority_Group_order priority_group_order, Thread_queue_Context *queue_context) |
Propagates a thread priority value change in the specified thread priority node to the corresponding thread priority aggregation. | |
void | _Thread_Priority_update (Thread_queue_Context *queue_context) |
Updates the priority of all threads in the set. | |
Thread_Control * | _Thread_Get (Objects_Id id, ISR_lock_Context *lock_context) |
Gets a thread by its identifier. | |
Objects_Id | _Thread_Self_id (void) |
Gets the identifier of the calling thread. | |
Timestamp_Control | _Thread_Get_CPU_time_used (Thread_Control *the_thread) |
Updates the used cpu time for the heir and dispatches a new heir. | |
Timestamp_Control | _Thread_Get_CPU_time_used_locked (Thread_Control *the_thread) |
Gets the used processor time of the thread throughout its entire lifetime if the caller already acquired the thread state and home scheduler locks. | |
Timestamp_Control | _Thread_Get_CPU_time_used_after_last_reset (Thread_Control *the_thread) |
Gets the used processor time of the thread after the last CPU usage reset. | |
Objects_Id | _Thread_Wait_get_id (const Thread_Control *the_thread) |
Returns the object identifier of the object containing the current thread wait queue. | |
void | _Thread_Continue (Thread_Control *the_thread, Status_Control status) |
Cancels a blocking operation so that the thread can continue its execution. | |
void | _Thread_Timeout (Watchdog_Control *the_watchdog) |
General purpose thread wait timeout. | |
Status_Control | _Thread_Set_name (Thread_Control *the_thread, const char *name) |
Sets the name of the thread. | |
size_t | _Thread_Get_name (const Thread_Control *the_thread, char *buffer, size_t buffer_size) |
Gets the name of the thread. | |
Variables | |
const Thread_Control_add_on | _Thread_Control_add_ons [] |
Thread control add-ons. | |
const size_t | _Thread_Control_add_on_count |
Thread control add-on count. | |
const size_t | _Thread_Initial_thread_count |
Count of configured threads. | |
const size_t | _Thread_Maximum_name_size |
Maximum size of a thread name in characters (including the terminating '\0' character). | |
const size_t | _Thread_Maximum_TLS_size |
If this constant is greater than zero, then it defines the maximum thread-local storage size, otherwise the thread-local storage size is defined by the linker depending on the thread-local storage objects used by the application in the statically-linked executable. | |
Thread_Information | _Thread_Information |
The internal thread objects information. | |
const Thread_CPU_budget_operations | _Thread_CPU_budget_exhaust_timeslice |
These CPU budget operations allocate timeslices to the thread. | |
const Thread_CPU_budget_operations | _Thread_CPU_budget_reset_timeslice |
These CPU budget operations allocate timeslices to the thread. | |
const size_t | _Thread_Idle_stack_size |
The idle thread stack size in bytes. | |
const Thread_Idle_body | _Thread_Idle_body |
The idle thread body. | |
Thread_Zombie_registry | _Thread_Zombies |
This object is a registry for threads in the STATES_ZOMBIE state. | |
Objects_Id | _Thread_Global_constructor |
Object identifier of the global constructor thread. | |
Thread_Control * | _Thread_Allocated_fp |
This group contains the Thread Handler implementation.
This handler encapsulates functionality related to the management of threads. This includes the creation, deletion, and scheduling of threads.
The following variables are maintained as part of the per cpu data structure.
#define _Thread_queue_Heads_size sizeof(Thread_queue_Heads) |
Size of the thread queue heads of a particular application.
In SMP configurations, this value is provided via <rtems/confdefs.h>.
#define RTEMS_SCORE_ROBUST_THREAD_DISPATCH |
Enables a robust thread dispatch.
On each change of the thread dispatch disable level from one to zero the interrupt status is checked. In case interrupts are disabled and SMP is enabled or the CPU port needs it, then the system terminates with the fatal internal error INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT.
#define THREAD_API_FIRST THREAD_API_RTEMS |
This macro defines the first API which has threads.
#define THREAD_API_LAST THREAD_API_POSIX |
This macro defines the last API which has threads.
#define THREAD_DEFAULT_MAXIMUM_NAME_SIZE 16 |
The default maximum size of a thread name in characters (including the terminating '\0' character).
This is the default value for the application configuration option CONFIGURE_MAXIMUM_THREAD_NAME_SIZE.
#define THREAD_INFORMATION_DEFINE | ( | name, | |
api, | |||
cls, | |||
max | |||
) |
#define THREAD_INFORMATION_DEFINE_ZERO | ( | name, | |
api, | |||
cls | |||
) |
#define THREAD_LIFE_CHANGE_DEFERRED 0x8U |
Indicates that thread life changes are deferred.
If this flag is set, then the thread restart or delete requests are deferred until the protection and deferred change flags are cleared. It is used by pthread_setcanceltype().
#define THREAD_LIFE_DETACHED 0x10U |
Indicates that thread is detached.
If this flag is set, then the thread is detached. Detached threads do not wait during termination for other threads to join. See rtems_task_delete(), rtems_task_exit(), and pthread_detach().
#define THREAD_LIFE_PROTECTED 0x1U |
Indicates that the thread life is protected.
If this flag is set, then the thread restart or delete requests are deferred until the protection and deferred change flags are cleared. It is used by _Thread_Set_life_protection().
#define THREAD_LIFE_RESTARTING 0x2U |
Indicates that thread is restarting.
If this flag is set, then a thread restart request is in pending. See _Thread_Restart_self() and _Thread_Restart_other().
#define THREAD_LIFE_TERMINATING 0x4U |
Indicates that thread is terminating.
If this flag is set, then a thread termination request is in pending. See _Thread_Exit() and _Thread_Cancel().
#define THREAD_WAIT_STATE_INTEND_TO_BLOCK 0x1U |
Indicates that the thread begins with the blocking operation.
A blocking operation consists of an optional watchdog initialization and the setting of the appropriate thread blocking state with the corresponding scheduler block operation.
#define THREAD_WAIT_STATE_READY 0x0U |
Indicates that the thread does not wait on something.
In this wait state, the wait class is zero. This wait state is set initially by _Thread_Initialize() and after each wait operation once the thread is ready again.
typedef void(* Thread_Action_handler) (Thread_Control *the_thread, Thread_Action *action, ISR_lock_Context *lock_context) |
This type defines the prototype of thread action handlers.
The thread action handler will be called with interrupts disabled and a corresponding lock acquired, e.g. _Thread_State_acquire(). The handler may release the corresponding lock, e.g. _Thread_State_release(). If the lock is released, it shall be acquired before the handler returns using the lock context. The lock may be used to protect private data used by the action.
Since the action is passed to the handler additional data may be accessed via RTEMS_CONTAINER_OF().
[in,out] | the_thread | is the thread performing the action. |
[in,out] | action | is the thread action. |
[in,out] | lock_context | is the lock context to use for the optional lock release and acquire. |
typedef struct Thread_Configured_control Thread_Configured_control |
The configured thread control block.
This type is defined in <rtems/confdefs.h> and depends on the application configuration.
Type of the numeric argument of a thread entry function with at least one numeric argument.
This numeric argument type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type and then converted back to a pointer to void. The result will compare equal to the original pointer.
typedef unsigned int Thread_Life_state |
This type represents the thread life state.
The thread life state is orthogonal to the thread state used for synchronization primitives and blocking operations. The thread life state reflects changes triggered by thread restart and delete requests.
The individual state flags must be a power of two to allow use of bit operations to manipulate and evaluate the thread life state.
The configured thread queue heads.
In SMP configurations, this type is defined in <rtems/confdefs.h> and depends on the application configuration.
typedef unsigned int Thread_Wait_flags |
This type is able to contain several flags used to control the wait class and state of a thread.
The mutually exclusive wait class flags are
The mutually exclusive wait state flags are
enum Thread_APIs |
enum Thread_Cancel_state |
Indicates the resulting state of _Thread_Cancel().
Objects_Control * _Thread_Allocate_unlimited | ( | Objects_Information * | information | ) |
Return an inactive thread object or NULL.
NULL | No inactive object is available. |
object | An inactive object. |
Thread_Cancel_state _Thread_Cancel | ( | Thread_Control * | the_thread, |
Thread_Control * | executing, | ||
Thread_Life_state | life_states_to_clear | ||
) |
Cancels the thread.
[in,out] | the_thread | is the thread to cancel. |
[in,out] | executing | is the currently executing thread. |
[in,out] | life_states_to_clear | is the set of thread life states to clear for the thread to cancel. |
Thread_Life_state _Thread_Change_life | ( | Thread_Life_state | life_states_to_clear, |
Thread_Life_state | life_states_to_set, | ||
Thread_Life_state | ignored_life_states | ||
) |
Changes the life of currently executing thread.
life_states_to_clear | are the thread life states to clear. |
life_states_to_set | are the thread life states to set. |
ignored_life_states | are the ignored thread life states. |
States_Control _Thread_Clear_state | ( | Thread_Control * | the_thread, |
States_Control | state | ||
) |
Clears the specified thread state.
In the case the previous state is a non-ready state and the next state is the ready state, then the thread is unblocked by the scheduler.
[in,out] | the_thread | The thread. |
state | The state to clear. It must not be zero. |
States_Control _Thread_Clear_state_locked | ( | Thread_Control * | the_thread, |
States_Control | state | ||
) |
Clears the specified thread state without locking the lock context.
In the case the previous state is a non-ready state and the next state is the ready state, then the thread is unblocked by the scheduler.
[in,out] | the_thread | The thread. |
state | The state to clear. It must not be zero. |
Status_Control _Thread_Close | ( | Thread_Control * | the_thread, |
Thread_Control * | executing, | ||
Thread_queue_Context * | queue_context | ||
) |
Closes the thread.
Closes the thread object and starts the thread termination sequence. In case the executing thread is not terminated, then this function waits until the terminating thread reached the zombie state.
the_thread | is the thread to close. | |
[in,out] | executing | is the currently executing thread. |
[in,out] | queue_context | is the thread queue context. The caller shall have disabled interrupts using the thread queue context. |
STATUS_SUCCESSFUL | The operation was successful. |
STATUS_DEADLOCK | A deadlock occurred. |
void _Thread_Continue | ( | Thread_Control * | the_thread, |
Status_Control | status | ||
) |
Cancels a blocking operation so that the thread can continue its execution.
In case this function actually cancelled the blocking operation, then the thread wait return code is set to the specified status.
A specialization of this function is _Thread_Timeout().
[in,out] | the_thread | The thread. |
status | The thread wait status. |
void _Thread_CPU_budget_consume_and_yield | ( | Thread_Control * | the_thread | ) |
Consumes one time quantum of the available CPU budget of the thread and yields the thread if the available CPU budget is fully consumed.
While the thread enabled the non-preemptive mode or is not ready, no time quantum is consumed.
the_thread | is the thread to operate on. |
void _Thread_CPU_budget_do_nothing | ( | Thread_Control * | the_thread | ) |
Does nothing.
the_thread | is an unused parameter. |
void _Thread_CPU_budget_set_to_ticks_per_timeslice | ( | Thread_Control * | the_thread | ) |
Sets the available CPU budget of the thread to the configured clock ticks per timeslice.
the_thread | is the thread to set the available CPU budget. |
void _Thread_Create_idle | ( | void | ) |
Creates idle thread.
This routine creates the idle thread.
void _Thread_Dispatch | ( | void | ) |
Performs a thread dispatch if necessary.
This routine is responsible for transferring control of the processor from the executing thread to the heir thread. Once the heir is running an attempt is made to run the pending post-switch thread actions.
As part of this process, it is responsible for the following actions
On entry the thread dispatch level must be equal to zero.
void _Thread_Dispatch_direct | ( | Per_CPU_Control * | cpu_self | ) |
Directly do a thread dispatch.
Must be called with a thread dispatch disable level of one, otherwise the INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will occur. This function is useful for operations which synchronously block, e.g. self restart, self deletion, yield, sleep.
cpu_self | The current processor. |
RTEMS_NO_RETURN void _Thread_Dispatch_direct_no_return | ( | Per_CPU_Control * | cpu_self | ) |
Directly do a thread dispatch and do not return.
cpu_self | is the current processor. |
void _Thread_Dispatch_enable | ( | Per_CPU_Control * | cpu_self | ) |
Enables thread dispatching.
May perform a thread dispatch if necessary as a side-effect.
[in,out] | cpu_self | The current processor. |
void _Thread_Do_dispatch | ( | Per_CPU_Control * | cpu_self, |
ISR_Level | level | ||
) |
Performs a thread dispatch on the current processor.
On entry the thread dispatch disable level must be equal to one and interrupts must be disabled.
This function assumes that a thread dispatch is necessary.
cpu_self | The current processor. |
level | The previous interrupt level. |
void _Thread_Entry_adaptor_idle | ( | Thread_Control * | executing | ) |
Calls the start kinds idle entry of the thread.
executing | The currently executing thread. |
void _Thread_Entry_adaptor_numeric | ( | Thread_Control * | executing | ) |
Calls the start kinds numeric entry of the thread.
executing | The currently executing thread. |
void _Thread_Entry_adaptor_pointer | ( | Thread_Control * | executing | ) |
Calls the start kinds pointer entry of the thread.
Stores the return value in the Wait.return_argument of the thread.
executing | The currently executing thread. |
RTEMS_NO_RETURN void _Thread_Exit | ( | void * | exit_value, |
Thread_Life_state | life_states_to_set | ||
) |
Exits the currently executing thread.
exit_value | is the exit value of the thread. |
life_states_to_set | are the thread life states to set. |
void _Thread_Free | ( | Thread_Information * | information, |
Thread_Control * | the_thread | ||
) |
Frees the thread.
This routine invokes the thread delete extensions and frees all resources associated with the thread. Afterwards the thread object is closed.
[in,out] | information | is the thread information. |
[in,out] | the_thread | is the thread to free. |
Thread_Control * _Thread_Get | ( | Objects_Id | id, |
ISR_lock_Context * | lock_context | ||
) |
Gets a thread by its identifier.
id | The id of the thread. |
lock_context | The lock context. |
Timestamp_Control _Thread_Get_CPU_time_used | ( | Thread_Control * | the_thread | ) |
Updates the used cpu time for the heir and dispatches a new heir.
[in,out] | cpu_self | The current processor. |
[in,out] | cpu_for_heir | The processor to do a dispatch on. |
heir | The new heir for cpu_for_heir. |
Gets the used processor time of the thread throughout its entire lifetime.
[in,out] | the_thread | is the thread. |
Timestamp_Control _Thread_Get_CPU_time_used_after_last_reset | ( | Thread_Control * | the_thread | ) |
Gets the used processor time of the thread after the last CPU usage reset.
[in,out] | the_thread | is the thread. |
Timestamp_Control _Thread_Get_CPU_time_used_locked | ( | Thread_Control * | the_thread | ) |
Gets the used processor time of the thread throughout its entire lifetime if the caller already acquired the thread state and home scheduler locks.
[in,out] | the_thread | is the thread. |
size_t _Thread_Get_name | ( | const Thread_Control * | the_thread, |
char * | buffer, | ||
size_t | buffer_size | ||
) |
Gets the name of the thread.
the_thread | The thread to get the name of. | |
[out] | buffer | Contains the thread's name. |
buffer_size | The size of buffer. |
void _Thread_Handler | ( | void | ) |
Wrapper function for all threads.
This routine is the wrapper function for all threads. It is the starting point for all threads. The user provided thread entry point is invoked by this routine. Operations which must be performed immediately before and after the user's thread executes are found here.
void _Thread_Handler_initialization | ( | void | ) |
Initializes thread handler.
This routine performs the initialization necessary for this handler.
Status_Control _Thread_Initialize | ( | Thread_Information * | information, |
Thread_Control * | the_thread, | ||
const Thread_Configuration * | config | ||
) |
Initializes thread.
This routine initializes the specified the thread. It allocates all memory associated with this thread. It completes by adding the thread to the local object table so operations on this thread id are allowed.
information | The thread information. |
the_thread | The thread to initialize. |
config | The configuration of the thread to initialize. |
STATUS_SUCCESSFUL | The thread initialization was successful. |
STATUS_UNSATISFIED | The thread initialization failed. |
void _Thread_Initialize_information | ( | Thread_Information * | information | ) |
Initializes the thread information.
[out] | information | Information to initialize. |
void _Thread_Iterate | ( | Thread_Visitor | visitor, |
void * | arg | ||
) |
Calls the visitor with all threads and the given argument until it is done.
visitor | Function that gets a thread and arg as parameters and returns if it is done. |
arg | Parameter for visitor |
Status_Control _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 thread.
[in,out] | the_thread | is the thread to join. |
waiting_for_join | is the thread state for the currently executing thread. | |
[in,out] | executing | is the currently executing thread. |
queue_context[in,out] | is the thread queue context. The caller shall have acquired the thread state lock using the thread queue context. |
STATUS_SUCCESSFUL | The operation was successful. |
STATUS_DEADLOCK | A deadlock occurred. |
void _Thread_Kill_zombies | ( | void | ) |
Kills all zombie threads in the system.
Threads change into the zombie state as the last step in the thread termination sequence right before a context switch to the heir thread is initiated. Since the thread stack is still in use during this phase we have to postpone the thread stack reclamation until this point. On SMP configurations we may have to busy wait for context switch completion here.
void _Thread_Load_environment | ( | Thread_Control * | the_thread | ) |
Initializes enviroment for a thread.
This routine initializes the context of the_thread to its appropriate starting state.
[in,out] | the_thread | The pointer to the thread control block. |
void _Thread_Priority_add | ( | Thread_Control * | the_thread, |
Priority_Node * | priority_node, | ||
Thread_queue_Context * | queue_context | ||
) |
Adds the specified thread priority node to the corresponding thread priority aggregation.
The caller must be the owner of the thread wait lock.
the_thread | The thread. |
priority_node | The thread priority node to add. |
queue_context | The thread queue context to return an updated set of threads for _Thread_Priority_update(). The thread queue context must be initialized via _Thread_queue_Context_clear_priority_updates() before a call of this function. |
void _Thread_Priority_changed | ( | Thread_Control * | the_thread, |
Priority_Node * | priority_node, | ||
Priority_Group_order | priority_group_order, | ||
Thread_queue_Context * | queue_context | ||
) |
Propagates a thread priority value change in the specified thread priority node to the corresponding thread priority aggregation.
The caller must be the owner of the thread wait lock.
the_thread | The thread. | |
[out] | priority_node | The thread priority node to change. |
priority_group_order | The priority group order determines if the thread is inserted as the first or last node into the ready or scheduled queues of its home scheduler, see PRIORITY_GROUP_FIRST and PRIORITY_GROUP_LAST. | |
queue_context | The thread queue context to return an updated set of threads for _Thread_Priority_update(). The thread queue context must be initialized via _Thread_queue_Context_clear_priority_updates() before a call of this function. |
void _Thread_Priority_perform_actions | ( | Thread_Control * | start_of_path, |
Thread_queue_Context * | queue_context | ||
) |
Checks if the thread is owner of the lock of the join queue.
the_thread | The thread for the verification. |
true | The thread is owner of the lock of the join queue. |
false | The thread is not owner of the lock of the join queue. |
Performs the priority actions specified by the thread queue context along the thread queue path.
The caller must be the owner of the thread wait lock.
start_of_path | The start thread of the thread queue path. |
queue_context | The thread queue context specifying the thread queue path and initial thread priority actions. |
void _Thread_Priority_remove | ( | Thread_Control * | the_thread, |
Priority_Node * | priority_node, | ||
Thread_queue_Context * | queue_context | ||
) |
Removes the specified thread priority node from the corresponding thread priority aggregation.
The caller must be the owner of the thread wait lock.
the_thread | The thread. |
priority_node | The thread priority node to remove. |
queue_context | The thread queue context to return an updated set of threads for _Thread_Priority_update(). The thread queue context must be initialized via _Thread_queue_Context_clear_priority_updates() before a call of this function. |
void _Thread_Priority_update | ( | Thread_queue_Context * | queue_context | ) |
Updates the priority of all threads in the set.
queue_context | The thread queue context to return an updated set of threads for _Thread_Priority_update(). The thread queue context must be initialized via _Thread_queue_Context_clear_priority_updates() before a call of this function. |
Status_Control _Thread_Restart | ( | Thread_Control * | the_thread, |
const Thread_Entry_information * | entry, | ||
ISR_lock_Context * | lock_context | ||
) |
Restarts the thread.
[in,out] | the_thread | is the thread to restart. |
entry | is the new start entry information for the thread to restart. | |
[in,out] | lock_context | is the lock context with interrupts disabled. |
STATUS_SUCCESSFUL | The operation was successful. |
STATUS_INCORRECT_STATE | The thread was dormant. |
Objects_Id _Thread_Self_id | ( | void | ) |
Gets the identifier of the calling thread.
Thread_Life_state _Thread_Set_life_protection | ( | Thread_Life_state | state | ) |
Set the thread to life protected.
Calls _Thread_Change_life with the given state AND THREAD_LIFE_PROTECTED to set and THREAD_LIFE_PROTECTED to clear.
state | The states to set. |
Status_Control _Thread_Set_name | ( | Thread_Control * | the_thread, |
const char * | name | ||
) |
Sets the name of the thread.
[out] | the_thread | The thread to change the name of. |
name | The new name for the thread. |
STATUS_SUCCESSFUL | The operation succeeded. |
STATUS_RESULT_TOO_LARGE | The name was too long. |
States_Control _Thread_Set_state | ( | Thread_Control * | the_thread, |
States_Control | state | ||
) |
Sets the specified thread state.
In the case the previous state is the ready state, then the thread is blocked by the scheduler.
[in,out] | the_thread | The thread. |
state | The state to set. It must not be zero. |
States_Control _Thread_Set_state_locked | ( | Thread_Control * | the_thread, |
States_Control | state | ||
) |
Sets the specified thread state without locking the lock context.
In the case the previous state is the ready state, then the thread is blocked by the scheduler.
[in,out] | the_thread | The thread. |
state | The state to set. It must not be zero. |
Status_Control _Thread_Start | ( | Thread_Control * | the_thread, |
const Thread_Entry_information * | entry, | ||
ISR_lock_Context * | lock_context | ||
) |
Starts the specified thread.
If the thread is not in the dormant state, the routine returns with a value of false and performs no actions except enabling interrupts as indicated by the ISR lock context.
Otherwise, this routine initializes the executable information for the thread and makes it ready to execute. After the call of this routine, the thread competes with all other ready threads for CPU time.
Then the routine enables the local interrupts as indicated by the ISR lock context.
Then the thread start user extensions are called with thread dispatching disabled and interrupts enabled after making the thread ready. Please note that in SMP configurations, the thread switch and begin user extensions may be called in parallel on another processor.
Then thread dispatching is enabled and other threads may execute before the routine returns.
[in,out] | the_thread | is the thread to start. |
entry | is the thread entry information. | |
[in,out] | is | the ISR lock context which shall be used to disable the local interrupts before the call of this routine. |
STATUS_SUCCESSFUL | The thread start was successful. |
STATUS_INCORRECT_STATE | The thread was already started. |
RTEMS_NO_RETURN void _Thread_Start_multitasking | ( | void | ) |
Starts thread multitasking.
This routine initiates multitasking. It is invoked only as part of initialization and its invocation is the last act of the non-multitasking part of the system initialization.
void _Thread_Timeout | ( | Watchdog_Control * | the_watchdog | ) |
General purpose thread wait timeout.
the_watchdog | The thread timer watchdog. |
Objects_Id _Thread_Wait_get_id | ( | const Thread_Control * | the_thread | ) |
Returns the object identifier of the object containing the current thread wait queue.
This function may be used for debug and system information purposes. The caller must be the owner of the thread lock.
the_thread | The thread. |
0 | The thread waits on no thread queue currently, the thread wait queue is not contained in an object, or the current thread state provides insufficient information, e.g. the thread is in the middle of a blocking operation. |
other | The object identifier of the object containing the thread wait queue. |
void _Thread_Yield | ( | Thread_Control * | executing | ) |
Yields the currently executing thread.
[in,out] | executing | The thread that performs a yield. |
void rtems_iterate_over_all_threads | ( | rtems_per_thread_routine | routine | ) |
Deprecated, use rtems_task_iterate() instead.
Use rtems_task_iterate() instead.
|
extern |
The following points to the thread whose floating point context is currently loaded.
|
extern |
Thread control add-on count.
Count of entries in _Thread_Control_add_ons.
This value is provided via <rtems/confdefs.h>.
|
extern |
Thread control add-ons.
The thread control block contains fields that point to application configuration dependent memory areas, like the scheduler information, the API control blocks, the user extension context table, and the Newlib re-entrancy support. Account for these areas in the configuration and avoid extra workspace allocations for these areas.
This array is provided via <rtems/confdefs.h>.
|
extern |
These CPU budget operations allocate timeslices to the thread.
The timeslice is not reset at a context switch to the thread. Once a timeslice is consumed, the thread yields.
|
extern |
These CPU budget operations allocate timeslices to the thread.
The timeslice is reset at a context switch to the thread. Once a timeslice is consumed, the thread yields.
|
extern |
Object identifier of the global constructor thread.
This variable is set by _RTEMS_tasks_Initialize_user_tasks_body() or _POSIX_Threads_Initialize_user_threads_body().
It is consumed by _Thread_Handler().
|
extern |
The idle thread body.
This constant is defined by the application configuration via <rtems/confdefs.h>.
|
extern |
The idle thread stack size in bytes.
This constant is defined by the application configuration via <rtems/confdefs.h>.
|
extern |
Count of configured threads.
This value is provided via <rtems/confdefs.h>.
|
extern |
Maximum size of a thread name in characters (including the terminating '\0' character).
This value is provided via <rtems/confdefs.h>.
|
extern |
If this constant is greater than zero, then it defines the maximum thread-local storage size, otherwise the thread-local storage size is defined by the linker depending on the thread-local storage objects used by the application in the statically-linked executable.
This value is provided via <rtems/confdefs.h>.
|
extern |
This object is a registry for threads in the STATES_ZOMBIE state.
The registry contains zombie threads waiting to get killed by _Thread_Kill_zombies(). Use _Thread_Add_to_zombie_registry() to add zombie threads to the registry.