unofficial-rtos-docs

Chapter 4 - Description of ThreadX Services

This chapter contains a description of all ThreadX services in alphabetic order. Their names are designed so all similar services are grouped together. In the Return Values section in the following descriptions, values in BOLD are not affected by the TX_DISABLE_ERROR_CHECKING define used to disable API error checking; while values shown in nonbold are completely disabled. In addition, a “Yes” listed under the “Preemption Possible” heading indicates that calling the service may resume a higher-priority thread, thus preempting the calling thread.

tx_block_allocate

Allocate fixed-size block of memory

Prototype

UINT tx_block_allocate(
    TX_BLOCK_POOL *pool_ptr, 
    VOID **block_ptr,
    ULONG wait_option);

Description

This service allocates a fixed-size memory block from the specified memory pool. The actual size of the memory block is determined during memory pool creation.

Important: It is important to ensure application code does not write outside the allocated memory block. If this happens, corruption occurs in an adjacent (usually subsequent) memory block. The results are unpredictable and often fatal!

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_BLOCK_POOL my_pool;
unsigned char *memory_ptr;

UINT status;

/* Allocate a memory block from my_pool. Assume that the pool has
already been created with a call to tx_block_pool_create. */

status = tx_block_allocate(&my_pool, (VOID **) &memory_ptr,
  TX_NO_WAIT);

/* If status equals TX_SUCCESS, memory_ptr contains the address of
the allocated block of memory. */

See Also

tx_block_pool_create

Create pool of fixed-size memory blocks

Prototype

UINT tx_block_pool_create(
    TX_BLOCK_POOL pool_ptr,
    CHAR name_ptr, 
    ULONG block_size,
    VOID pool_start, 
    ULONG pool_size);

Description

This service creates a pool of fixed-size memory blocks. The memory area specified is divided into as many fixed-size memory blocks as possible using the formula:

total blocks = (total bytes) / (block size + sizeof(void *))

Note: Each memory block contains one pointer of overhead that is invisible to the user and is represented by the “sizeof(void *)” in the preceding formula.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_BLOCK_POOL my_pool;

UINT status;

/* Create a memory pool whose total size is 1000 bytes starting at
address 0x100000. Each block in this pool is defined to be 50 bytes
long. */
status = tx_block_pool_create(&my_pool, "my_pool_name",
  50, (VOID *) 0x100000, 1000);

/* If status equals TX_SUCCESS, my_pool contains 18 memory blocks
of 50 bytes each. The reason there are not 20 blocks in the pool is
because of the one overhead pointer associated with each block. */

See Also

tx_block_pool_delete

Delete memory block pool

Prototype

UINT tx_block_pool_delete(TX_BLOCK_POOL *pool_ptr);

Description

This service deletes the specified block-memory pool. All threads suspended waiting for a memory block from this pool are resumed and given a TX_DELETED return status.

Note: It is the application’s responsibility to manage the memory area associated with the pool, which is available after this service completes. In addition, the application must prevent use of a deleted pool or its former memory blocks.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_BLOCK_POOL my_pool;

UINT           status;

/* Delete entire memory block
pool. Assume that the pool has already been created with a call to
tx_block_pool_create. */
status = tx_block_pool_delete(&my_pool);

/* If status equals TX_SUCCESS, the memory block pool is deleted.*/

See Also

tx_block_pool_info_get

Retrieve information about block pool

Prototype

UINT tx_block_pool_info_get(
    TX_BLOCK_POOL *pool_ptr, 
    CHAR **name,
    ULONG *available, 
    ULONG *total_blocks,
    TX_THREAD **first_suspended,
    ULONG *suspended_count,
    TX_BLOCK_POOL **next_pool);

Description

This service retrieves information about the specified block memory pool.

Parameters

Note: Supplying a TX_NULL for any parameter indicates the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BLOCK_POOL my_pool;
CHAR *name;
ULONG available;
ULONG total_blocks;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_BLOCK_POOL *next_pool;
UINT status;

/* Retrieve information about the previously created
block pool "my_pool." */
status = tx_block_pool_info_get(&my_pool, &name,
  &available,&total_blocks,
  &first_suspended, &suspended_count,
  &next_pool);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_block_pool_performance_info_get

Get block pool performance information

Prototype

UINT tx_block_pool_performance_info_get(
    TX_BLOCK_POOL *pool_ptr,
    ULONG *allocates, 
    ULONG *releases,
    ULONG *suspensions, 
    ULONG *timeouts));

Description

This service retrieves performance information about the specified memory block pool.

Important: The ThreadX library and application must be built with TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BLOCK_POOL my_pool;
ULONG allocates;
ULONG releases;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on the previously created block
pool. */
status = tx_block_pool_performance_info_get(&my_pool, &allocates,
  &releases,
  &suspensions,
  &timeouts);

/* If status is TX_SUCCESS the performance information was successfully retrieved. */

See Also

tx_block_pool_performance_system_info_get

Get block pool system performance information

Prototype

UINT tx_block_pool_performance_system_info_get(
    ULONG *allocates,
    ULONG *releases, 
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about all memory block pools in the application.

Important: The ThreadX library and application must be built with TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG       allocates;
ULONG       releases;
ULONG       suspensions;
ULONG       timeouts;

/* Retrieve performance information on all the block pools in
the system. */
status = tx_block_pool_performance_system_info_get(&allocates,
    &releases,&suspensions, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_block_pool_prioritize

Prioritize block pool suspension list

Prototype

UINT tx_block_pool_prioritize(TX_BLOCK_POOL *pool_ptr);

Description

This service places the highest priority thread suspended for a block of memory on this pool at the front of the suspension list. All other threads remain in the same FIFO order they were suspended in.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BLOCK_POOL my_pool;
UINT status;

/* Ensure that the highest priority thread will receive
the next free block in this pool. */
status = tx_block_pool_prioritize(&my_pool);

/* If status equals TX_SUCCESS, the highest priority
suspended thread is at the front of the list. The
next tx_block_release call will wake up this thread. */

See Also

tx_block_release

Release fixed-size block of memory

Prototype

UINT tx_block_release(VOID *block_ptr);

Description

This service releases a previously allocated block back to its associated memory pool. If there are one or more threads suspended waiting for memory blocks from this pool, the first thread suspended is given this memory block and resumed.

Note: The application may want to clear the memory block before releasing it to prevent data leaks.

Important: The application must prevent using a memory block area after it has been released back to the pool.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_BLOCK_POOL my_pool;
unsigned char *memory_ptr;
UINT status;

/* Release a memory block back to my_pool. Assume that the
pool has been created and the memory block has been
allocated. */
status = tx_block_release((VOID *) memory_ptr);

/* If status equals TX_SUCCESS, the block of memory pointed
to by memory_ptr has been returned to the pool. */

See Also

tx_byte_allocate

Allocate bytes of memory

Prototype

UINT tx_byte_allocate(
    TX_BYTE_POOL *pool_ptr,
    VOID **memory_ptr, 
    ULONG memory_size,
    ULONG wait_option);

Description

This service allocates the specified number of bytes from the specified memory byte pool.

Important: It is important to ensure application code does not write outside the allocated memory block. If this happens, corruption occurs in an adjacent (usually subsequent) memory block. The results are unpredictable and often fatal!

Note: The performance of this service is a function of the block size and the amount of fragmentation in the pool. Hence, this service should not be used during time-critical threads of execution.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

Yes

Example

TX_BYTE_POOL my_pool;
unsigned char*memory_ptr;
UINT status;
/* Allocate a 112 byte memory area from my_pool. Assume
that the pool has already been created with a call to
tx_byte_pool_create. */
status = tx_byte_allocate(&my_pool, (VOID **) &memory_ptr,
    112, TX_NO_WAIT);

/* If status equals TX_SUCCESS, memory_ptr contains the
address of the allocated memory area. */

See Also

tx_byte_pool_create

Create memory pool of bytes

Prototype

UINT tx_byte_pool_create(
    TX_BYTE_POOL *pool_ptr,
    CHAR *name_ptr, 
    VOID *pool_start,
    ULONG pool_size);

Description

This service creates a memory byte pool in the area specified. Initially the pool consists of basically one very large free block. However, the pool is broken into smaller blocks as allocations are made.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_BYTE_POOL my_pool;
UINT status;
/* Create a memory pool whose total size is 2000 bytes
starting at address 0x500000. */
status = tx_byte_pool_create(&my_pool, "my_pool_name",
    (VOID *) 0x500000, 2000);

/* If status equals TX_SUCCESS, my_pool is available for
allocating memory. */

See Also

tx_byte_pool_delete

Delete memory byte pool

Prototype

UINT tx_byte_pool_delete(TX_BYTE_POOL *pool_ptr);

Description

This service deletes the specified memory byte pool. All threads suspended waiting for memory from this pool are resumed and given a TX_DELETED return status.

Important: It is the application’s responsibility to manage the memory area associated with the pool, which is available after this service completes. In addition, the application must prevent use of a deleted pool or memory previously allocated from it.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_BYTE_POOL my_pool;
UINT status;
/* Delete entire memory pool. Assume that the pool has already
been created with a call to tx_byte_pool_create. */
status = tx_byte_pool_delete(&my_pool);

/* If status equals TX_SUCCESS, memory pool is deleted. */

See Also

tx_byte_pool_info_get

Retrieve information about byte pool

Prototype

UINT tx_byte_pool_info_get(
    TX_BYTE_POOL *pool_ptr, 
    CHAR **name,
    ULONG *available, 
    ULONG *fragments,
    TX_THREAD **first_suspended,
    ULONG *suspended_count,
    TX_BYTE_POOL **next_pool);

Description

This service retrieves information about the specified memory byte pool.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BYTE_POOL my_pool;
CHAR *name;
ULONG available;
ULONG fragments;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_BYTE_POOL *next_pool;
UINT status;

/* Retrieve information about the previously created
block pool "my_pool." */
status = tx_byte_pool_info_get(&my_pool, &name,
  &available, &fragments,
  &first_suspended, &suspended_count,
  &next_pool);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_byte_pool_performance_info_get

Get byte pool performance information

Prototype

UINT tx_byte_pool_performance_info_get(
    TX_BYTE_POOL *pool_ptr,
    ULONG *allocates, 
    ULONG *releases,
    ULONG *fragments_searched, 
    ULONG *merges, 
    ULONG *splits,
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about the specified memory byte pool.

Important: The ThreadX library and application must be built with TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BYTE_POOL my_pool;
ULONG fragments_searched;
ULONG merges;
ULONG splits;
ULONG allocates;
ULONG releases;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on the previously created byte
pool. */
status = tx_byte_pool_performance_info_get(&my_pool,
  &fragments_searched,
  &merges, &splits,
  &allocates, &releases,
  &suspensions,&timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_byte_pool_performance_system_info_get

Get byte pool system performance information

Prototype

UINT tx_byte_pool_performance_system_info_get(
    ULONG *allocates,
    ULONG *releases, 
    ULONG *fragments_searched, 
    ULONG *merges,
    ULONG *splits, 
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about all memory byte pools in the system.

Important: The ThreadX library and application must be built with TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG fragments_searched;
ULONG merges;
ULONG splits;
ULONG allocates;
ULONG releases;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on all byte pools in the
system. */
status =
tx_byte_pool_performance_system_info_get(&fragments_searched,
  &merges, &splits, &allocates, &releases,
  &suspensions, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_byte_pool_prioritize

Prioritize byte pool suspension list

Prototype

UINT tx_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr);

Description

This service places the highest priority thread suspended for memory on this pool at the front of the suspension list. All other threads remain in the same FIFO order they were suspended in.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_BYTE_POOL my_pool;
UINT status;

/* Ensure that the highest priority thread will receive
the next free memory from this pool. */
status = tx_byte_pool_prioritize(&my_pool);

/* If status equals TX_SUCCESS, the highest priority
suspended thread is at the front of the list. The
next tx_byte_release call will wake up this thread,
if there is enough memory to satisfy its request. */

See Also

tx_byte_release

Release bytes back to memory pool

Prototype

UINT tx_byte_release(VOID *memory_ptr);

Description

This service releases a previously allocated memory area back to its associated pool. If there are one or more threads suspended waiting for memory from this pool, each suspended thread is given memory and resumed until the memory is exhausted or until there are no more suspended threads. This process of allocating memory to suspended threads always begins with the first thread suspended.

Note: The application may want to clear the memory area before releasing it to prevent data leaks.

Important: The application must prevent using the memory area after it is released.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

Yes

Example

unsigned char *memory_ptr;
UINT status;

/* Release a memory back to my_pool. Assume that the memory
area was previously allocated from my_pool. */
status = tx_byte_release((VOID *) memory_ptr);

/* If status equals TX_SUCCESS, the memory pointed to by
memory_ptr has been returned to the pool. */

See Also

tx_event_flags_create

Create event flags group

Prototype

UINT tx_event_flags_create(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    CHAR *name_ptr);

Description

This service creates a group of 32 event flags. All 32 event flags in the group are initialized to zero. Each event flag is represented by a single bit.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_EVENT_FLAGS_GROUP my_event_group;
UINT status;

/* Create an event flags group. */
status = tx_event_flags_create(&my_event_group,
  "my_event_group_name");

/* If status equals TX_SUCCESS, my_event_group is ready
for get and set services. */

See Also

tx_event_flags_delete

Delete event flags group

Prototype

UINT tx_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr);

Description

This service deletes the specified event flags group. All threads suspended waiting for events from this group are resumed and given a TX_DELETED return status.

Important: The application must ensure that a set notify callback for this event flags group is completed (or disabled) before deleting the event flags group. In addition, the application must prevent all future use of a deleted event flags group.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_EVENT_FLAGS_GROUP my_event_flags_group;
UINT status;

/* Delete event flags group. Assume that the group has
already been created with a call to
tx_event_flags_create. */
status = tx_event_flags_delete(&my_event_flags_group);

/* If status equals TX_SUCCESS, the event flags group is
deleted. */

See Also

tx_event_flags_get

Get event flags from event flags group

Prototype

UINT tx_event_flags_get(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    ULONG requested_flags, 
    UINT get_option,
    ULONG *actual_flags_ptr, 
    ULONG wait_option);

Description

This service retrieves event flags from the specified event flags group. Each event flags group contains 32 event flags. Each flag is represented by a single bit. This service can retrieve a variety of event flag combinations, as selected by the input parameters.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_EVENT_FLAGS_GROUP my_event_flags_group;
ULONG actual_events;
UINT status;

/* Request that event flags 0, 4, and 8 are all set. Also,
if they are set they should be cleared. If the event
flags are not set, this service suspends for a maximum of
20 timer-ticks. */
status = tx_event_flags_get(&my_event_flags_group, 0x111,
    TX_AND_CLEAR, &actual_events, 20);

/* If status equals TX_SUCCESS, actual_events contains the
actual events obtained. */

See Also

tx_event_flags_info_get

Retrieve information about event flags group

Prototype

UINT tx_event_flags_info_get(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    CHAR **name, ULONG *current_flags,
    TX_THREAD **first_suspended,
    ULONG *suspended_count,
    TX_EVENT_FLAGS_GROUP **next_group);

Description

This service retrieves information about the specified event flags group.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_EVENT_FLAGS_GROUP my_event_group;
CHAR *name;
ULONG current_flags;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_EVENT_FLAGS_GROUP *next_group;
UINT status;

/* Retrieve information about the previously created
event flags group "my_event_group." */
status = tx_event_flags_info_get(&my_event_group, &name,
    &current_flags,
    &first_suspended, &suspended_count,
    &next_group);
/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_event_flags_performance_info_get

Get event flags group performance information

Prototype

UINT tx_event_flags_performance_info_get(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    ULONG *sets, ULONG *gets,
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about the specified event flags group.

Important: ThreadX library and application must be built with *TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO: defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_EVENT_FLAGS_GROUP my_event_flag_group;
ULONG sets;
ULONG gets;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on the previously created event
flag group. */
status = tx_event_flags_performance_info_get(&my_event_flag_group,
    &sets, &gets, &suspensions,
    &timeouts);

/* If status is TX_SUCCESS the performance information was successfully
retrieved. */

See Also

tx_event_flags_performance_system_info_get

Retrieve performance system information

Prototype

UINT tx_event_flags_performance_system_info_get(
    ULONG *sets,
    ULONG *gets,
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about all event flags groups in the system.

Important: ThreadX library and application must be built with TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG sets;
ULONG gets;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on all previously created event
flag groups. */
status = tx_event_flags_performance_system_info_get(&sets, &gets,
    &suspensions, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_event_flags_set

Set event flags in an event flags group

Prototype

UINT tx_event_flags_set(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    ULONG flags_to_set,
    UINT set_option);

Description

This service sets or clears event flags in an event flags group, depending upon the specified set-option. All suspended threads whose event flags request is now satisfied are resumed.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_EVENT_FLAGS_GROUP my_event_flags_group;
UINT status;

/* Set event flags 0, 4, and 8. */
status = tx_event_flags_set(&my_event_flags_group,
    0x111, TX_OR);

/* If status equals TX_SUCCESS, the event flags have been
set and any suspended thread whose request was satisfied
has been resumed. */

See Also

tx_event_flags_set_notify

Notify application when event flags are set

Prototype

UINT tx_event_flags_set_notify(
    TX_EVENT_FLAGS_GROUP *group_ptr,
    VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *));

Description

This service registers a notification callback function that is called whenever one or more event flags are set in the specified event flags group. The processing of the notification callback is defined by the

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_EVENT_FLAGS_GROUP my_group;

/* Register the "my_event_flags_set_notify" function for monitoring
event flags set in the event flags group "my_group." */
status = tx_event_flags_set_notify(&my_group, my_event_flags_set_notify);

/* If status is TX_SUCCESS the event flags set notification function
was successfully registered. */
void my_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr)

/* One or more event flags was set in this group! */

See Also

tx_interrupt_control

Enable and disable interrupts

Prototype

UINT tx_interrupt_control(UINT new_posture);

Description

This service enables or disables interrupts as specified by the input parameter new_posture.

Note: If this service is called from an application thread, the interrupt posture remains part of that thread’s context. For example, if the thread calls this routine to disable interrupts and then suspends, when it is resumed, interrupts are disabled again.

Warning: This service should not be used to enable interrupts during initialization! Doing so could cause unpredictable results.

Parameters

Return Values

Allowed From

Threads, timers, and ISRs

Preemption Possible

No

Example

UINT my_old_posture;

/* Lockout interrupts */
my_old_posture = tx_interrupt_control(TX_INT_DISABLE);

/* Perform critical operations that need interrupts
locked-out.... */

/* Restore previous interrupt lockout posture. */
tx_interrupt_control(my_old_posture);

See Also

None

tx_mutex_create

Create mutual exclusion mutex

Prototype

UINT tx_mutex_create(
    TX_MUTEX *mutex_ptr,
    CHAR *name_ptr, 
    UINT priority_inherit);

Description

This service creates a mutex for inter-thread mutual exclusion for resource protection.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_MUTEX my_mutex;
UINT status;

/* Create a mutex to provide protection over a
common resource. */
status = tx_mutex_create(&my_mutex,"my_mutex_name",
    TX_NO_INHERIT);

/* If status equals TX_SUCCESS, my_mutex is ready for
use. */

See Also

tx_mutex_delete

Delete mutual exclusion mutex

Prototype

UINT tx_mutex_delete(TX_MUTEX *mutex_ptr);

Description

This service deletes the specified mutex. All threads suspended waiting for the mutex are resumed and given a TX_DELETED return status.

Note: It is the application’s responsibility to prevent use of a deleted mutex.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_MUTEX my_mutex;
UINT status;

/* Delete a mutex. Assume that the mutex
has already been created. */
status = tx_mutex_delete(&my_mutex);

/* If status equals TX_SUCCESS, the mutex is
deleted. */

See Also

tx_mutex_get

Obtain ownership of mutex

Prototype

UINT tx_mutex_get(
    TX_MUTEX *mutex_ptr, 
    ULONG wait_option);

Description

This service attempts to obtain exclusive ownership of the specified mutex. If the calling thread already owns the mutex, an internal counter is incremented and a successful status is returned.

If the mutex is owned by another thread and this thread is higher priority and priority inheritance was specified at mutex create, the lower priority thread’s priority will be temporarily raised to that of the calling thread.

Note: The priority of the lower priority thread owning a mutex with priority inheritance should never be modified by an external thread during mutex ownership.

Parameters

Return Values

Allowed From

Initialization and threads and timers

Preemption Possible

Yes

Example

TX_MUTEX my_mutex;
UINT status;

/* Obtain exclusive ownership of the mutex "my_mutex".
If the mutex "my_mutex" is not available, suspend until it
becomes available. */
status = tx_mutex_get(&my_mutex, TX_WAIT_FOREVER);

See Also

tx_mutex_info_get

Retrieve information about mutex

Prototype

UINT tx_mutex_info_get(
    TX_MUTEX *mutex_ptr, 
    CHAR **name,
    ULONG *count, 
    TX_THREAD **owner,
    TX_THREAD **first_suspended,
    ULONG *suspended_count, 
    TX_MUTEX **next_mutex);

Description

This service retrieves information from the specified mutex.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_MUTEX my_mutex;
CHAR *name;
ULONG count;
TX_THREAD *owner;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_MUTEX *next_mutex;
UINT status;

/* Retrieve information about the previously created
mutex "my_mutex." */
status = tx_mutex_info_get(&my_mutex, &name,
    &count, &owner,
    &first_suspended, &suspended_count,
    &next_mutex);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_mutex_performance_info_get

Get mutex performance information

Prototype

UINT tx_mutex_performance_info_get(
    TX_MUTEX *mutex_ptr, 
    ULONG *puts,
    ULONG *gets, 
    ULONG *suspensions, 
    ULONG *timeouts,
    ULONG *inversions, 
    ULONG *inheritances);

Description

This service retrieves performance information about the specified mutex.

Important: The ThreadX library and application must be built with TX_MUTEX_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_MUTEX my_mutex;
ULONG puts;
ULONG gets;
ULONG suspensions;
ULONG timeouts;
ULONG inversions;
ULONG inheritances;

/* Retrieve performance information on the previously created
mutex. */
status = tx_mutex_performance_info_get(&my_mutex_ptr, &puts, &gets,
    &suspensions, &timeouts, &inversions, &inheritances);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_mutex_performance_system_info_get

Get mutex system performance information

Prototype

UINT tx_mutex_performance_system_info_get(
    ULONG *puts, 
    ULONG *gets,
    ULONG *suspensions, 
    ULONG *timeouts,
    ULONG *inversions, 
    ULONG *inheritances);

Description

This service retrieves performance information about all the mutexes in the system.

Important: The ThreadX library and application must be built with TX_MUTEX_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG puts;
ULONG gets;
ULONG suspensions;
ULONG timeouts;
ULONG inversions;
ULONG inheritances;

/* Retrieve performance information on all previously created
mutexes. */
status = tx_mutex_performance_system_info_get(&puts, &gets,
    &suspensions, &timeouts,
    &inversions, &inheritances);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_mutex_prioritize

Prioritize mutex suspension list

Prototype

UINT tx_mutex_prioritize(TX_MUTEX *mutex_ptr);

Description

This service places the highest priority thread suspended for ownership of the mutex at the front of the suspension list. All other threads remain in the same FIFO order they were suspended in.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_MUTEX my_mutex;
UINT status;

/* Ensure that the highest priority thread will receive
ownership of the mutex when it becomes available. */
status = tx_mutex_prioritize(&my_mutex);

/* If status equals TX_SUCCESS, the highest priority
suspended thread is at the front of the list. The
next tx_mutex_put call that releases ownership of the
mutex will give ownership to this thread and wake it
up. */

See Also

tx_mutex_put

Release ownership of mutex

Prototype

UINT tx_mutex_put(TX_MUTEX *mutex_ptr);

Description

This service decrements the ownership count of the specified mutex. If the ownership count is zero, the mutex is made available.

Note: If priority inheritance was selected during mutex creation, the priority of the releasing thread will be restored to the priority it had when it originally obtained ownership of the mutex. Any other priority changes made to the releasing thread during ownership of the mutex may be undone.

Parameters

Return Values

Allowed From

Initialization and threads and timers

Preemption Possible

Yes

Example

TX_MUTEX my_mutex;
UINT status;

/* Release ownership of "my_mutex." */
status = tx_mutex_put(&my_mutex);

/* If status equals TX_SUCCESS, the mutex ownership
count has been decremented and if zero, released. */

See Also

tx_queue_create

Create message queue

Prototype

UINT tx_queue_create(
    TX_QUEUE *queue_ptr, 
    CHAR *name_ptr,
    UINT message_size,
    VOID *queue_start, 
    ULONG queue_size);

Description

This service creates a message queue that is typically used for interthread communication. The total number of messages is calculated from the specified message size and the total number of bytes in the queue.

Note: If the total number of bytes specified in the queue’s memory area is not evenly divisible by the specified message size, the remaining bytes in the memory area are not used.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_QUEUE my_queue;
UINT status;

/* Create a message queue whose total size is 2000 bytes
starting at address 0x300000. Each message in this
queue is defined to be 4 32-bit words long. */
status = tx_queue_create(&my_queue, "my_queue_name",
    4, (VOID *) 0x300000, 2000);

/* If status equals TX_SUCCESS, my_queue contains room
for storing 125 messages (2000 bytes/ 16 bytes per
message). */

See Also

tx_queue_delete

Delete message queue

Prototype

UINT tx_queue_delete(TX_QUEUE *queue_ptr);

Description

This service deletes the specified message queue. All threads suspended waiting for a message from this queue are resumed and given a TX_DELETED return status.

Important: The application must ensure that any send notify callback for this queue is completed (or disabled) before deleting the queue. In addition, the application must prevent any future use of a deleted queue.

It is also the application’s responsibility to manage the memory area associated with the queue, which is available after this service completes.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_QUEUE my_queue;
UINT status;

/* Delete entire message queue. Assume that the queue
has already been created with a call to
tx_queue_create. */
status = tx_queue_delete(&my_queue);

/* If status equals TX_SUCCESS, the message queue is
deleted. */

See Also

tx_queue_flush

Empty messages in message queue

Prototype

UINT tx_queue_flush(TX_QUEUE *queue_ptr);

Description

This service deletes all messages stored in the specified message queue.

If the queue is full, messages of all suspended threads are discarded. Each suspended thread is then resumed with a return status that indicates the message send was successful. If the queue is empty, this service does nothing.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_QUEUE my_queue;
UINT status;

/* Flush out all pending messages in the specified message
queue. Assume that the queue has already been created
with a call to tx_queue_create. */
status = tx_queue_flush(&my_queue);

/* If status equals TX_SUCCESS, the message queue is
empty. */

See Also

tx_queue_front_send

Send message to the front of queue

Prototype

UINT tx_queue_front_send(
    TX_QUEUE *queue_ptr,
    VOID *source_ptr, 
    ULONG wait_option);

Description

This service sends a message to the front location of the specified message queue. The message is copied to the front of the queue from the memory area specified by the source pointer.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_QUEUE my_queue;
UINT status;
ULONG my_message[4];

/* Send a message to the front of "my_queue." Return
immediately, regardless of success. This wait
option is used for calls from initialization, timers,
and ISRs. */
status = tx_queue_front_send(&my_queue, my_message,
    TX_NO_WAIT);

/* If status equals TX_SUCCESS, the message is at the front
of the specified queue. */

See Also

tx_queue_info_get

Retrieve information about queue

Prototype

UINT tx_queue_info_get(
    TX_QUEUE *queue_ptr, 
    CHAR **name,
    ULONG *enqueued, 
    ULONG *available_storage
    TX_THREAD **first_suspended, 
    ULONG *suspended_count,
    TX_QUEUE **next_queue);

Description

This service retrieves information about the specified message queue.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_QUEUE my_queue;
CHAR *name;
ULONG enqueued;
ULONG available_storage;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_QUEUE *next_queue;
UINT status;

/* Retrieve information about the previously created
message queue "my_queue." */
status = tx_queue_info_get(&my_queue, &name,
    &enqueued, &available_storage,
    &first_suspended, &suspended_count,
    &next_queue);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_queue_performance_info_get

Get queue performance information

Prototype

UINT tx_queue_performance_info_get(
    TX_QUEUE *queue_ptr,
    ULONG *messages_sent, 
    ULONG *messages_received,
    ULONG *empty_suspensions, 
    ULONG *full_suspensions,
    ULONG *full_errors, 
    ULONG *timeouts);

Description

This service retrieves performance information about the specified queue.

Important: The ThreadX library and application must be built with TX_QUEUE_ENABLE_PERFORMANCE_INFO: *defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_QUEUE my_queue;
ULONG messages_sent;
ULONG messages_received;
ULONG empty_suspensions;
ULONG full_suspensions;
ULONG full_errors;
ULONG timeouts;

/* Retrieve performance information on the previously created
queue. */
status = tx_queue_performance_info_get(&my_queue, &messages_sent,
    &messages_received, &empty_suspensions,
    &full_suspensions, &full_errors, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_queue_performance_system_info_get

Get queue system performance information

Prototype

UINT tx_queue_performance_system_info_get(
    ULONG *messages_sent,
    ULONG *messages_received, 
    ULONG *empty_suspensions,
    ULONG *full_suspensions, 
    ULONG *full_errors,
    ULONG *timeouts);

Description

This service retrieves performance information about all the queues in the system.

Important: The ThreadX library and application must be built with TX_QUEUE_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG messages_sent;
ULONG messages_received;
ULONG empty_suspensions;
ULONG full_suspensions;
ULONG full_errors;
ULONG timeouts;

/* Retrieve performance information on all previously created
queues. */
status = tx_queue_performance_system_info_get(&messages_sent,
    &messages_received, &empty_suspensions,
    &full_suspensions, &full_errors, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_queue_prioritize

Prioritize queue suspension list

Prototype

UINT tx_queue_prioritize(TX_QUEUE *queue_ptr);

Description

This service places the highest priority thread suspended for a message (or to place a message) on this queue at the front of the suspension list.

All other threads remain in the same FIFO order they were suspended in.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_QUEUE my_queue;
UINT status;

/* Ensure that the highest priority thread will receive
the next message placed on this queue. */
status = tx_queue_prioritize(&my_queue);

/* If status equals TX_SUCCESS, the highest priority
suspended thread is at the front of the list. The
next tx_queue_send or tx_queue_front_send call made
to this queue will wake up this thread. */

See Also

tx_queue_receive

Get message from message queue

Prototype

UINT tx_queue_receive(
    TX_QUEUE *queue_ptr,
    VOID *destination_ptr, 
    ULONG wait_option);

Description

This service retrieves a message from the specified message queue. The retrieved message is copied from the queue into the memory area specified by the destination pointer. That message is then removed from the queue.

Important: The specified destination memory area must be large enough to hold the message; i.e., the message destination pointed to by destination_ptr must be at least as large as the message size for this queue. Otherwise, if the destination is not large enough, memory corruption occurs in the following memory area.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_QUEUE my_queue;
UINT status;
ULONG my_message[4];

/* Retrieve a message from "my_queue." If the queue is
empty, suspend until a message is present. Note that
this suspension is only possible from application
threads. */
status = tx_queue_receive(&my_queue, my_message,
    TX_WAIT_FOREVER);

/* If status equals TX_SUCCESS, the message is in
"my_message." */

See Also

tx_queue_send

Send message to message queue

Prototype

UINT tx_queue_send(
    TX_QUEUE *queue_ptr,
    VOID *source_ptr, 
    ULONG wait_option);

Description

This service sends a message to the specified message queue. The sent message is copied to the queue from the memory area specified by the source pointer.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_QUEUE my_queue;
UINT status;
ULONG my_message[4];

/* Send a message to "my_queue." Return immediately,
regardless of success. This wait option is used for
calls from initialization, timers, and ISRs. */
status = tx_queue_send(&my_queue, my_message, TX_NO_WAIT);

/* If status equals TX_SUCCESS, the message is in the
queue. */

See Also

tx_queue_send_notify

Notify application when message is sent to queue

Prototype

UINT tx_queue_send_notify(
    TX_QUEUE *queue_ptr,
    VOID (*queue_send_notify)(TX_QUEUE *));

Description

This service registers a notification callback function that is called whenever a message is sent to the specified queue. The processing of the notification callback is defined by the application.

Note: The application’s queue send notification callback is not allowed to call any ThreadX API with a suspension option.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_QUEUE my_queue;
/* Register the "my_queue_send_notify" function for monitoring
messages sent to the queue "my_queue." */
status = tx_queue_send_notify(&my_queue, my_queue_send_notify);

/* If status is TX_SUCCESS the queue send notification function was
successfully registered. */
void my_queue_send_notify(TX_QUEUE *queue_ptr)
{
    /* A message was just sent to this queue! */
}

See Also

tx_semaphore_ceiling_put

Place an instance in counting semaphore with ceiling

Prototype

UINT tx_semaphore_ceiling_put(
    TX_SEMAPHORE *semaphore_ptr,
    ULONG ceiling);

Description

This service puts an instance into the specified counting semaphore, which in reality increments the counting semaphore by one. If the counting semaphore’s current value is greater than or equal to the specified ceiling, the instance will not be put and a TX_CEILING_EXCEEDED error will be returned.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_SEMAPHORE my_semaphore;

/* Increment the counting semaphore "my_semaphore" but make sure
that it never exceeds 7 as specified in the call. */
status = tx_semaphore_ceiling_put(&my_semaphore, 7);

/* If status is TX_SUCCESS the semaphore count has been
incremented. */

See Also

tx_semaphore_create

Create counting semaphore

Prototype

UINT tx_semaphore_create(
    TX_SEMAPHORE *semaphore_ptr,
    CHAR *name_ptr, 
    ULONG initial_count);

Description

This service creates a counting semaphore for inter-thread synchronization. The initial semaphore count is specified as an input parameter.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_SEMAPHORE my_semaphore;
UINT status;

/* Create a counting semaphore whose initial value is 1.
This is typically the technique used to make a binary
semaphore. Binary semaphores are used to provide
protection over a common resource. */
status = tx_semaphore_create(&my_semaphore,
    "my_semaphore_name", 1);

/* If status equals TX_SUCCESS, my_semaphore is ready for
use. */

See Also

tx_semaphore_delete

Delete counting semaphore

Prototype

UINT tx_semaphore_delete(TX_SEMAPHORE *semaphore_ptr);

Description

This service deletes the specified counting semaphore. All threads suspended waiting for a semaphore instance are resumed and given a TX_DELETED return status.

Important: The application must ensure that a put notify callback for this semaphore is completed (or disabled) before deleting the semaphore. In addition, the application must prevent all future use of a deleted semaphore.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_SEMAPHORE my_semaphore;
UINT status;

/* Delete counting semaphore. Assume that the counting
semaphore has already been created. */
status = tx_semaphore_delete(&my_semaphore);

/* If status equals TX_SUCCESS, the counting semaphore is
deleted. */

See Also

tx_semaphore_get

Get instance from counting semaphore

Prototype

UINT tx_semaphore_get(
    TX_SEMAPHORE *semaphore_ptr,
    ULONG wait_option);

Description

This service retrieves an instance (a single count) from the specified counting semaphore. As a result, the specified semaphore’s count is decreased by one.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_SEMAPHORE my_semaphore;
UINT status;

/* Get a semaphore instance from the semaphore
"my_semaphore." If the semaphore count is zero,
suspend until an instance becomes available.
Note that this suspension is only possible from
application threads. */
status = tx_semaphore_get(&my_semaphore, TX_WAIT_FOREVER);

/* If status equals TX_SUCCESS, the thread has obtained
an instance of the semaphore. */

See Also

tx_semaphore_info_get

Retrieve information about semaphore

Prototype

UINT tx_semaphore_info_get(
    TX_SEMAPHORE *semaphore_ptr,
    CHAR **name, ULONG *current_value,
    TX_THREAD **first_suspended,
    ULONG *suspended_count,
    TX_SEMAPHORE **next_semaphore);

Description

This service retrieves information about the specified semaphore.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_SEMAPHORE my_semaphore;
CHAR *name;
ULONG current_value;
TX_THREAD *first_suspended;
ULONG suspended_count;
TX_SEMAPHORE *next_semaphore;
UINT status;

/* Retrieve information about the previously created
semaphore "my_semaphore." */
status = tx_semaphore_info_get(&my_semaphore, &name,
    &current_value,
    &first_suspended, &suspended_count,
    &next_semaphore);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_semaphore_performance_info_get

Get semaphore performance information

Prototype

UINT tx_semaphore_performance_info_get(
    TX_SEMAPHORE *semaphore_ptr,
    ULONG *puts, 
    ULONG *gets,
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about the specified semaphore.

Important: The ThreadX library and application must be built with TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_SEMAPHORE my_semaphore;
ULONG puts;
ULONG gets;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on the previously created
semaphore. */
status = tx_semaphore_performance_info_get(&my_semaphore, &puts,
    &gets, &suspensions, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_semaphore_performance_system_info_get

Get semaphore system performance information

Prototype

UINT tx_semaphore_performance_system_info_get(
    ULONG *puts,
    ULONG *gets, 
    ULONG *suspensions, 
    ULONG *timeouts);

Description

This service retrieves performance information about all the semaphores in the system.

Important: The ThreadX library and application must be built with TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO defined for this service to return performance information

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG puts;
ULONG gets;
ULONG suspensions;
ULONG timeouts;

/* Retrieve performance information on all previously created
semaphores. */
status = tx_semaphore_performance_system_info_get(&puts, &gets,
    &suspensions, &timeouts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_semaphore_prioritize

Prioritize semaphore suspension list

Prototype

UINT tx_semaphore_prioritize(TX_SEMAPHORE *semaphore_ptr);

Description

This service places the highest priority thread suspended for an instance of the semaphore at the front of the suspension list. All other threads remain in the same FIFO order they were suspended in.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_SEMAPHORE my_semaphore;
UINT status;

/* Ensure that the highest priority thread will receive
the next instance of this semaphore. */
status = tx_semaphore_prioritize(&my_semaphore);

/* If status equals TX_SUCCESS, the highest priority
suspended thread is at the front of the list. The
next tx_semaphore_put call made to this semaphore will
wake up this thread. */

See Also

tx_semaphore_put

Place an instance in counting semaphore

Prototype

UINT tx_semaphore_put(TX_SEMAPHORE *semaphore_ptr);

Description

This service puts an instance into the specified counting semaphore, which in reality increments the counting semaphore by one.

Note: If this service is called when the semaphore is all ones (OxFFFFFFFF), the new put operation will cause the semaphore to be reset to zero.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_SEMAPHORE my_semaphore;
UINT status;

/* Increment the counting semaphore "my_semaphore." */
status = tx_semaphore_put(&my_semaphore);

/* If status equals TX_SUCCESS, the semaphore count has
been incremented. Of course, if a thread was waiting,
it was given the semaphore instance and resumed. */

See Also

tx_semaphore_put_notify

Notify application when semaphore is put

Prototype

UINT tx_semaphore_put_notify(
    TX_SEMAPHORE *semaphore_ptr,
    VOID (*semaphore_put_notify)(TX_SEMAPHORE *));

Description

This service registers a notification callback function that is called whenever the specified semaphore is put. The processing of the notification callback is defined by the application.

Note: The application’s semaphore notification callback is not allowed to call any ThreadX API with a suspension option.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_SEMAPHORE my_semaphore;

/* Register the "my_semaphore_put_notify" function for monitoring
the put operations on the semaphore "my_semaphore." */
status = tx_semaphore_put_notify(&my_semaphore, my_semaphore_put_notify);

/* If status is TX_SUCCESS the semaphore put notification function
was successfully registered. */
void my_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr)
{
    /* The semaphore was just put! */
}

See Also

tx_thread_create

Create application thread

Prototype

UINT tx_thread_create(
    TX_THREAD *thread_ptr,
    CHAR *name_ptr, 
    VOID (*entry_function)(ULONG),
    ULONG entry_input, 
    VOID *stack_start,
    ULONG stack_size, 
    UINT priority,
    UINT preempt_threshold, 
    ULONG time_slice,
    UINT auto_start);

Description

This service creates an application thread that starts execution at the specified task entry function. The stack, priority, preemption-threshold, and time-slice are among the attributes specified by the input parameters. In addition, the initial execution state of the thread is also specified.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT status;

/* Create a thread of priority 15 whose entry point is
"my_thread_entry". This thread's stack area is 1000
bytes in size, starting at address 0x400000. The
preemption-threshold is setup to allow preemption of threads
with priorities ranging from 0 through 14. Time-slicing is
disabled. This thread is automatically put into a ready
condition. */
status = tx_thread_create(&my_thread, "my_thread_name",
    my_thread_entry, 0x1234,
    (VOID *) 0x400000, 1000,
    15, 15, TX_NO_TIME_SLICE,
    TX_AUTO_START);

/* If status equals TX_SUCCESS, my_thread is ready
for execution! */

...

/* Thread's entry function. When "my_thread" actually
begins execution, control is transferred to this
function. */

VOID my_thread_entry (ULONG initial_input)
{
    /* When we get here, the value of initial_input is
    0x1234. See how this was specified during
    creation. */
    /* The real work of the thread, including calls to
    other function should be called from here! */
    /* When this function returns, the corresponding
    thread is placed into a "completed" state. */
}

See Also

tx_thread_delete

Delete application thread

Prototype

UINT tx_thread_delete(TX_THREAD *thread_ptr);

Description

This service deletes the specified application thread. Since the specified thread must be in a terminated or completed state, this service cannot be called from a thread attempting to delete itself.

Note: It is the application’s responsibility to manage the memory area associated with the thread’s stack, which is available after this service completes. In addition, the application must prevent use of a deleted thread.

Parameters

Return Values

Allowed From

Threads and timers

Preemption Possible

No

Example

TX_THREAD my_thread;
UINT status;

/* Delete an application thread whose control block is
"my_thread". Assume that the thread has already been
created with a call to tx_thread_create. */
status = tx_thread_delete(&my_thread);

/* If status equals TX_SUCCESS, the application thread is
deleted. */

See Also

tx_thread_entry_exit_notify

Notify application upon thread entry and exit

Prototype

UINT tx_thread_entry_exit_notify(
    TX_THREAD *thread_ptr,
    VOID (*entry_exit_notify)(TX_THREAD *, UINT));

Description

This service registers a notification callback function that is called whenever the specified thread is entered or exits. The processing of the notification callback is defined by the application.

Note: The application’s thread entry/exit notification callback is not allowed to call any ThreadX API with a suspension option.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_THREAD my_thread;
/* Register the "my_entry_exit_notify" function for monitoring
the entry/exit of the thread "my_thread." */
status = tx_thread_entry_exit_notify(&my_thread,
    my_entry_exit_notify);

/* If status is TX_SUCCESS the entry/exit notification function was
successfully registered. */
void my_entry_exit_notify(TX_THREAD *thread_ptr, UINT condition)
{
    /* Determine if the thread was entered or exited. */
    if (condition == TX_THREAD_ENTRY)
        /* Thread entry! */
    else if (condition == TX_THREAD_EXIT)
        /* Thread exit! */
}

See Also

tx_thread_identify

Retrieves pointer to currently executing thread

Prototype

TX_THREAD* tx_thread_identify(VOID);

Description

This service returns a pointer to the currently executing thread. If no thread is executing, this service returns a null pointer.

Note: If this service is called from an ISR, the return value represents the thread running prior to the executing interrupt handler.

Parameters

None

Return Values

Allowed From

Threads and ISRs

Preemption Possible

No

Example

TX_THREAD *my_thread_ptr;

/* Find out who we are! */
my_thread_ptr = tx_thread_identify();

/* If my_thread_ptr is non-null, we are currently executing
from that thread or an ISR that interrupted that thread.
Otherwise, this service was called
from an ISR when no thread was running when the
interrupt occurred. */

See Also

tx_thread_info_get

Retrieve information about thread

Prototype

UINT tx_thread_info_get(
    TX_THREAD *thread_ptr, 
    CHAR **name,
    UINT *state, 
    ULONG *run_count,
    UINT *priority,
    UINT *preemption_threshold,
    ULONG *time_slice,
    TX_THREAD **next_thread,
    TX_THREAD **suspended_thread);

Description

This service retrieves information about the specified thread.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_THREAD my_thread;
CHAR *name;
UINT state;
ULONG run_count;
UINT priority;
UINT preemption_threshold;
UINT time_slice;
TX_THREAD *next_thread;
TX_THREAD *suspended_thread;
UINT status;

/* Retrieve information about the previously created
thread "my_thread." */

status = tx_thread_info_get(&my_thread, &name,
    &state, &run_count,
    &priority, &preemption_threshold,
    &time_slice, &next_thread,&suspended_thread);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_thread_performance_info_get

Get thread performance information

Prototype

UINT tx_thread_performance_info_get(
    TX_THREAD *thread_ptr,
    LONG *resumptions, 
    ULONG *suspensions,
    ULONG *solicited_preemptions, 
    ULONG *interrupt_preemptions,
    ULONG *priority_inversions, 
    ULONG *time_slices,
    ULONG *relinquishes, 
    ULONG *timeouts, 
    ULONG *wait_aborts,
    TX_THREAD **last_preempted_by);

Description

This service retrieves performance information about the specified thread.

Important: The ThreadX library and application must be built with TX_THREAD_ENABLE_PERFORMANCE_INFO defined in order for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_THREAD my_thread;
ULONG resumptions;
ULONG suspensions;
ULONG solicited_preemptions;
ULONG interrupt_preemptions;
ULONG priority_inversions;
ULONG time_slices;
ULONG relinquishes;
ULONG timeouts;
ULONG wait_aborts;
TX_THREAD *last_preempted_by;

/* Retrieve performance information on the previously created
thread. */

status = tx_thread_performance_info_get(&my_thread, &resumptions,
    &suspensions,
    &solicited_preemptions, &interrupt_preemptions,
    &priority_inversions, &time_slices,
    &relinquishes, &timeouts,
    &wait_aborts, &last_preempted_by);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_thread_performance_system_info_get

Get thread system performance information

Prototype

UINT tx_thread_performance_system_info_get(
    ULONG *resumptions,
    ULONG *suspensions, 
    ULONG *solicited_preemptions,
    ULONG *interrupt_preemptions, 
    ULONG *priority_inversions,
    ULONG *time_slices, 
    ULONG *relinquishes, 
    ULONG *timeouts,
    ULONG *wait_aborts, 
    ULONG *non_idle_returns,
    ULONG *idle_returns);

Description

This service retrieves performance information about all the threads in the system.

The ThreadX library and application must be built with

TX_THREAD_ENABLE_PERFORMANCE_INFO defined in order for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG resumptions;
ULONG suspensions;
ULONG solicited_preemptions;
ULONG interrupt_preemptions;
ULONG priority_inversions;
ULONG time_slices;
ULONG relinquishes;
ULONG timeouts;
ULONG wait_aborts;
ULONG non_idle_returns;
ULONG idle_returns;

/* Retrieve performance information on all previously created
thread. */

status = tx_thread_performance_system_info_get(&resumptions,
    &suspensions,
    &solicited_preemptions, &interrupt_preemptions,
    &priority_inversions, &time_slices, &relinquishes,
    &timeouts, &wait_aborts, &non_idle_returns,
    &idle_returns);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_thread_preemption_change

Change preemption-threshold of application thread

Prototype

UINT tx_thread_preemption_change(
    TX_THREAD *thread_ptr,
    UINT new_threshold, 
    UINT *old_threshold);

Description

This service changes the preemption-threshold of the specified thread. The preemption-threshold prevents preemption of the specified thread by threads equal to or less than the preemption-threshold value.

Note: Using preemption-threshold disables time-slicing for the specified thread.

Parameters

Return Values

Allowed From

Threads and timers

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT my_old_threshold;
UINT status;

/* Disable all preemption of the specified thread. The
current preemption-threshold is returned in
"my_old_threshold". Assume that "my_thread" has
already been created. */

status = tx_thread_preemption_change(&my_thread,
    0, &my_old_threshold);

/* If status equals TX_SUCCESS, the application thread is
non-preemptable by another thread. Note that ISRs are
not prevented by preemption disabling. */

See Also

tx_thread_priority_change

Change priority of application thread

Prototype

UINT tx_thread_priority_change(
    TX_THREAD *thread_ptr,
    UINT new_priority, 
    UINT *old_priority);

Description

This service changes the priority of the specified thread. Valid priorities range from 0 through (TX_MAX_PRIORITIES-1), where 0 represents the highest priority level.

Important: The preemption-threshold of the specified thread is automatically set to the new priority. If a new threshold is desired, the *tx_thread_preemption_change service must be used after this call.*

Parameters

Return Values

Allowed From

Threads and timers

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT my_old_priority;
UINT status;

/* Change the thread represented by "my_thread" to priority
0. */

status = tx_thread_priority_change(&my_thread,
    0, &my_old_priority);

/* If status equals TX_SUCCESS, the application thread is
now at the highest priority level in the system. */

See Also

tx_thread_relinquish

Relinquish control to other application threads

Prototype

VOID tx_thread_relinquish(VOID);

Description

This service relinquishes processor control to other ready-to-run threads at the same or higher priority.

Note: In addition to relinquishing control to threads of the same priority, this service also relinquishes control to the highest-priority thread prevented from execution because of the current thread’s preemption-threshold setting.

Parameters

None

Return Values

None

Allowed From

Threads

Preemption Possible

Yes

Example

ULONG run_counter_1 = 0;
ULONG run_counter_2 = 0;

/* Example of two threads relinquishing control to
each other in an infinite loop. Assume that
both of these threads are ready and have the same
priority. The run counters will always stay within one
of each other. */

VOID my_first_thread(ULONG thread_input)
{
    /* Endless loop of relinquish. */
    while(1)
    {
        /* Increment the run counter. */
        run_counter_1++;

        /* Relinquish control to other thread. */
        tx_thread_relinquish();
    }
}

VOID my_second_thread(ULONG thread_input)
{

    /* Endless loop of relinquish. */
    while(1)
    {
        /* Increment the run counter. */
        run_counter_2++;

        /* Relinquish control to other thread. */
        tx_thread_relinquish();
    }
}

See Also

tx_thread_reset

Reset thread

Prototype

UINT tx_thread_reset(TX_THREAD *thread_ptr);

Description

This service resets the specified thread to execute at the entry point defined at thread creation. The thread must be in either a TX_COMPLETED or TX_TERMINATED state for it to be reset

Important: The thread must be resumed for it to execute again.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

TX_THREAD my_thread;

/* Reset the previously created thread "my_thread." */

status = tx_thread_reset(&my_thread);

/* If status is TX_SUCCESS the thread is reset. */

See Also

tx_thread_resume

Resume suspended application thread

Prototype

UINT tx_thread_resume(TX_THREAD *thread_ptr);

Description

This service resumes or prepares for execution a thread that was previously suspended by a tx_thread_suspend call. In addition, this service resumes threads that were created without an automatic start.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

TX_THREAD my_thread;

Example

TX_THREAD my_thread;
UINT status;

/* Resume the thread represented by "my_thread". */
status = tx_thread_resume(&my_thread);

/* If status equals TX_SUCCESS, the application thread is
now ready to execute. */

See Also

tx_thread_sleep

Suspend current thread for specified time

Prototype

UINT tx_thread_sleep(ULONG timer_ticks);

Description

This service causes the calling thread to suspend for the specified number of timer ticks. The amount of physical time associated with a timer tick is application specific. This service can be called only from an application thread.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

Yes

Example

UINT status;

/* Make the calling thread sleep for 100
timer-ticks. */
status = tx_thread_sleep(100);

/* If status equals TX_SUCCESS, the currently running
application thread slept for the specified number of
timer-ticks. */

See Also

tx_thread_stack_error_notify

Register thread stack error notification callback

Prototype

UINT tx_thread_stack_error_notify(VOID (*error_handler)(TX_THREAD *));

Description

This service registers a notification callback function for handling thread stack errors. When ThreadX detects a thread stack error during execution, it will call this notification function to process the error. Processing of the error is completely defined by the application. Anything from suspending the violating thread to resetting the entire system may be done.

Important: The ThreadX library must be built with TX_ENABLE_STACK_CHECKING defined in order for this service to return performance information.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

void my_stack_error_handler(TX_THREAD *thread_ptr);

/* Register the "my_stack_error_handler" function with ThreadX
so that thread stack errors can be handled by the application. */
status = tx_thread_stack_error_notify(my_stack_error_handler);

/* If status is TX_SUCCESS the stack error handler is registered.*/

See Also

tx_thread_suspend

Suspend application thread

Prototype

UINT tx_thread_suspend(TX_THREAD *thread_ptr);

Description

This service suspends the specified application thread. A thread may call this service to suspend itself.

Note: If the specified thread is already suspended for another reason, this suspension is held internally until the prior suspension is lifted. When that happens, this unconditional suspension of the specified thread is performed. Further unconditional suspension requests have no effect.

After being suspended, the thread must be resumed by tx_thread_resume to execute again.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT status;

/* Suspend the thread represented by "my_thread". */
status = tx_thread_suspend(&my_thread);

/* If status equals TX_SUCCESS, the application thread is
unconditionally suspended. */

See Also

tx_thread_terminate

Terminates application thread

Prototype

UINT tx_thread_terminate(TX_THREAD *thread_ptr);

Description

This service terminates the specified application thread regardless of whether the thread is suspended or not. A thread may call this service to terminate itself.

Note: It is the application’s responsibility to ensure that the thread is in a state suitable for termination. For example, a thread should not be terminated during critical application processing or inside of other middleware components where it could leave such processing in an unknown state.

Important: After being terminated, the thread must be reset for it to execute again.

Parameters

Return Values

Allowed From

Threads and timers

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT status;

/* Terminate the thread represented by "my_thread". */
status = tx_thread_terminate(&my_thread);

/* If status equals TX_SUCCESS, the thread is terminated
and cannot execute again until it is reset. */

See Also

tx_thread_time_slice_change

Changes time-slice of application thread

Prototype

UINT tx_thread_time_slice_change(
    TX_THREAD *thread_ptr,
    ULONG new_time_slice, 
    ULONG *old_time_slice);

Description

This service changes the time-slice of the specified application thread. Selecting a time-slice for a thread insures that it won’t execute more than the specified number of timer ticks before other threads of the same or higher priorities have a chance to execute.

Note: Using preemption-threshold disables time-slicing for the specified thread.

Parameters

Return Values

Allowed From

Threads and timers

Preemption Possible

No

Example

TX_THREAD my_thread;
ULONG my_old_time_slice;
UINT status;

/* Change the time-slice of the thread associated with
"my_thread" to 20. This will mean that "my_thread"
can only run for 20 timer-ticks consecutively before
other threads of equal or higher priority get a chance
to run. */
status = tx_thread_time_slice_change(&my_thread, 20,
    &my_old_time_slice);

/* If status equals TX_SUCCESS, the thread's time-slice
has been changed to 20 and the previous time-slice is
in "my_old_time_slice." */

See Also

tx_thread_wait_abort

Abort suspension of specified thread

Prototype

UINT tx_thread_wait_abort(TX_THREAD *thread_ptr);

Description

This service aborts sleep or any other object suspension of the specified thread. If the wait is aborted, a TX_WAIT_ABORTED value is returned from the service that the thread was waiting on.

Note: This service does not release explicit suspension that is made by the tx_thread_suspend service.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

Yes

Example

TX_THREAD my_thread;
UINT status;

/* Abort the suspension condition of "my_thread." */
status = tx_thread_wait_abort(&my_thread);

/* If status equals TX_SUCCESS, the thread is now ready
again, with a return value showing its suspension
was aborted (TX_WAIT_ABORTED). */

See Also

tx_time_get

Retrieves the current time

Application Timers

Prototype

ULONG tx_time_get(VOID);

Description

This service returns the contents of the internal system clock. Each timertick increases the internal system clock by one. The system clock is set to zero during initialization and can be changed to a specific value by the service tx_time_set.

Note: The actual time each timer-tick represents is application specific.

Parameters

None

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG current_time;

/* Pickup the current system time, in timer-ticks. */
current_time = tx_time_get();

/* Current time now contains a copy of the internal system
clock. */

See Also

tx_time_set

Sets the current time

Prototype

VOID tx_time_set(ULONG new_time);

Description

This service sets the internal system clock to the specified value. Each timer-tick increases the internal system clock by one.

Note: The actual time each timer-tick represents is application specific.

Parameters

Return Values

None

Allowed From

Threads, timers, and ISRs

Preemption Possible

No

Example

/* Set the internal system time to 0x1234. */
tx_time_set(0x1234);

/* Current time now contains 0x1234 until the next timer
interrupt. */

See Also

tx_timer_activate

Activate application timer

Prototype

UINT tx_timer_activate(TX_TIMER *timer_ptr);

Description

This service activates the specified application timer. The expiration routines of timers that expire at the same time are executed in the order they were activated.

Note: An expired one-shot timer must be reset via tx_timer_change before it can be activated again.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_TIMER my_timer;
UINT status;

/* Activate an application timer. Assume that the
application timer has already been created. */
status = tx_timer_activate(&my_timer);

/* If status equals TX_SUCCESS, the application timer is
now active. */

See Also

tx_timer_change

Change application timer

Prototype

UINT tx_timer_change(
    TX_TIMER *timer_ptr,
    ULONG initial_ticks, 
    ULONG reschedule_ticks);

Description

This service changes the expiration characteristics of the specified application timer. The timer must be deactivated prior to calling this service.

Note: A call to the tx_timer_activate service is required after this service in order to start the timer again.

Parameters

Note: An expired one-shot timer must be reset via tx_timer_change before it can be activated again.

Return Values

Allowed From

Threads, timers, and ISRs

Preemption Possible

No

Example

TX_TIMER my_timer;
UINT status;

/* Change a previously created and now deactivated timer
to expire every 50 timer ticks, including the initial
expiration. */
status = tx_timer_change(&my_timer,50, 50);

/* If status equals TX_SUCCESS, the specified timer is
changed to expire every 50 ticks. */

/* Activate the specified timer to get it started again. */
status = tx_timer_activate(&my_timer);

See Also

tx_timer_create

Create application timer

Prototype

UINT tx_timer_create(
    TX_TIMER *timer_ptr, 
    CHAR *name_ptr,
    VOID (*expiration_function)(ULONG),
    ULONG expiration_input, 
    ULONG initial_ticks,
    ULONG reschedule_ticks, 
    UINT auto_activate);

Description

This service creates an application timer with the specified expiration function and periodic.

Parameters

Return Values

Allowed From

Initialization and threads

Preemption Possible

No

Example

TX_TIMER my_timer;
UINT status;

/* Create an application timer that executes
"my_timer_function" after 100 ticks initially and then
after every 25 ticks. This timer is specified to start
immediately! */
status = tx_timer_create(&my_timer,"my_timer_name",
    my_timer_function, 0x1234, 100, 25,
    TX_AUTO_ACTIVATE);

/* If status equals TX_SUCCESS, my_timer_function will
be called 100 timer ticks later and then called every
25 timer ticks. Note that the value 0x1234 is passed to
my_timer_function every time it is called. */

See Also

tx_timer_deactivate

Deactivate application timer

Prototype

UINT tx_timer_deactivate(TX_TIMER *timer_ptr);

Description

This service deactivates the specified application timer. If the timer is already deactivated, this service has no effect.

Parameters

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_TIMER my_timer;
UINT status;

/* Deactivate an application timer. Assume that the
application timer has already been created. */
status = tx_timer_deactivate(&my_timer);

/* If status equals TX_SUCCESS, the application timer is
now deactivated. */

See Also

tx_timer_delete

Delete application timer

Prototype

UINT tx_timer_delete(TX_TIMER *timer_ptr);

Description

This service deletes the specified application timer.

Note: It is the application’s responsibility to prevent use of a deleted timer.

Parameters

Return Values

Allowed From

Threads

Preemption Possible

No

Example

TX_TIMER my_timer;
UINT status;

/* Delete application timer. Assume that the application
timer has already been created. */
status = tx_timer_delete(&my_timer);

/* If status equals TX_SUCCESS, the application timer is
deleted. */

See Also

tx_timer_info_get

Retrieve information about an application timer

Prototype

UINT tx_timer_info_get(
    TX_TIMER *timer_ptr, 
    CHAR **name,
    UINT *active,
    ULONG *remaining_ticks,
    ULONG *reschedule_ticks,
    TX_TIMER **next_timer);

Description

This service retrieves information about the specified application timer.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_TIMER my_timer;
CHAR *name;
UINT active;
ULONG remaining_ticks;
ULONG reschedule_ticks;
TX_TIMER *next_timer;
UINT status;

/* Retrieve information about the previously created
application timer "my_timer." */
status = tx_timer_info_get(&my_timer, &name,
    &active,&remaining_ticks,
    &reschedule_ticks,
    &next_timer);

/* If status equals TX_SUCCESS, the information requested is
valid. */

See Also

tx_timer_performance_info_get

Get timer performance information

Prototype

UINT tx_timer_performance_info_get(
    TX_TIMER *timer_ptr,
    ULONG *activates, 
    ULONG *reactivates,
    ULONG *deactivates, 
    ULONG *expirations,
    ULONG *expiration_adjusts);

Description

This service retrieves performance information about the specified application timer.

Important: The ThreadX library and application must be built with TX_TIMER_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

TX_TIMER my_timer;
ULONG activates;
ULONG reactivates;
ULONG deactivates;
ULONG expirations;
ULONG expiration_adjusts;

/* Retrieve performance information on the previously created
timer. */
status = tx_timer_performance_info_get(&my_timer, &activates,
    &reactivates,&deactivates, &expirations,
    &expiration_adjusts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also

tx_timer_performance_system_info_get

Get timer system performance information

Prototype

UINT tx_timer_performance_system_info_get(
    ULONG *activates,
    ULONG *reactivates, 
    ULONG *deactivates,
    ULONG *expirations, 
    ULONG *expiration_adjusts);

Description

This service retrieves performance information about all the application timers in the system.

Important: The ThreadX library and application must be built with TX_TIMER_ENABLE_PERFORMANCE_INFO defined for this service to return performance information.

Parameters

Note: Supplying a TX_NULL for any parameter indicates that the parameter is not required.

Return Values

Allowed From

Initialization, threads, timers, and ISRs

Preemption Possible

No

Example

ULONG activates;
ULONG reactivates;
ULONG deactivates;
ULONG expirations;
ULONG expiration_adjusts;

/* Retrieve performance information on all previously created
timers. */
status = tx_timer_performance_system_info_get(&activates,
    &reactivates, &deactivates, &expirations,
    &expiration_adjusts);

/* If status is TX_SUCCESS the performance information was
successfully retrieved. */

See Also