In the ThreadX real-time operating system, the API functions that users can call cover various aspects such as task management, synchronization mechanisms, memory management, timers, event flags, message queues, and debugging. Below is a list of ThreadX user interface functions categorized by functionality:
1. Thread Management Functions
| Function | Interface Function |
|---|---|
| Create Thread | <span>tx_thread_create()</span> |
| Delete Thread | <span>tx_thread_delete()</span> |
| Sleep Thread | <span>tx_thread_sleep()</span> |
| Terminate Thread | <span>tx_thread_terminate()</span> |
| Suspend Thread | <span>tx_thread_suspend()</span> |
| Resume Thread | <span>tx_thread_resume()</span> |
| Get Current Thread Pointer | <span>tx_thread_identify()</span> |
| Get Thread Status | <span>tx_thread_info_get()</span> |
| Change Thread Priority | <span>tx_thread_priority_change()</span> |
| Force Scheduling | <span>tx_thread_relinquish()</span> |
| Set/Clear Interrupt Control for Scheduling | <span>tx_thread_interrupt_control()</span> |
2. Semaphore Management Functions
| Function | Interface Function |
|---|---|
| Create Semaphore | <span>tx_semaphore_create()</span> |
| Delete Semaphore | <span>tx_semaphore_delete()</span> |
| Get Semaphore | <span>tx_semaphore_get()</span> |
| Put Semaphore | <span>tx_semaphore_put()</span> |
| Get Semaphore Information | <span>tx_semaphore_info_get()</span> |
3. Mutex Management Functions
| Function | Interface Function |
|---|---|
| Create Mutex | <span>tx_mutex_create()</span> |
| Delete Mutex | <span>tx_mutex_delete()</span> |
| Get Mutex | <span>tx_mutex_get()</span> |
| Put Mutex | <span>tx_mutex_put()</span> |
| Get Mutex Information | <span>tx_mutex_info_get()</span> |
4. Event Flags Management Functions
| Function | Interface Function |
|---|---|
| Create Event Flags | <span>tx_event_flags_create()</span> |
| Delete Event Flags | <span>tx_event_flags_delete()</span> |
| Set Flags | <span>tx_event_flags_set()</span> |
| Clear Flags | <span>tx_event_flags_set()</span> (use <span>TX_AND_CLEAR</span> for clearing) |
| Get Flags | <span>tx_event_flags_get()</span> |
| Get Event Information | <span>tx_event_flags_info_get()</span> |
5. Queue Management Functions
| Function | Interface Function |
|---|---|
| Create Queue | <span>tx_queue_create()</span> |
| Delete Queue | <span>tx_queue_delete()</span> |
| Send Message | <span>tx_queue_send()</span> |
| Receive Message | <span>tx_queue_receive()</span> |
| Get Queue Information | <span>tx_queue_info_get()</span> |
6. Block Memory Pool Management Functions
| Function | Interface Function |
|---|---|
| Create Memory Pool | <span>tx_block_pool_create()</span> |
| Delete Memory Pool | <span>tx_block_pool_delete()</span> |
| Allocate Memory Block | <span>tx_block_allocate()</span> |
| Release Memory Block | <span>tx_block_release()</span> |
| Get Memory Pool Information | <span>tx_block_pool_info_get()</span> |
7. Byte Memory Pool Management Functions
| Function | Interface Function |
|---|---|
| Create Byte Pool | <span>tx_byte_pool_create()</span> |
| Delete Byte Pool | <span>tx_byte_pool_delete()</span> |
| Allocate Memory | <span>tx_byte_allocate()</span> |
| Release Memory | <span>tx_byte_release()</span> |
| Get Byte Pool Information | <span>tx_byte_pool_info_get()</span> |
8. Timer Management Functions
| Function | Interface Function |
|---|---|
| Create Timer | <span>tx_timer_create()</span> |
| Delete Timer | <span>tx_timer_delete()</span> |
| Activate Timer | <span>tx_timer_activate()</span> |
| Deactivate Timer | <span>tx_timer_deactivate()</span> |
| Change Timer | <span>tx_timer_change()</span> |
| Get Timer Information | <span>tx_timer_info_get()</span> |
9. System Control Interfaces
| Function | Interface Function |
|---|---|
| Start Kernel | <span>tx_kernel_enter()</span> |
| Initialize Thread Control Block | <span>tx_thread_entry_exit_notify()</span> |
| Get System Version | <span>tx_version_id_get()</span> |
10. Interrupt Control Interfaces (for Bare Metal Encapsulation)
| Function | Interface Function |
|---|---|
| Disable Interrupts | <span>tx_interrupt_control(TX_INT_DISABLE)</span> |
| Enable Interrupts | <span>tx_interrupt_control(TX_INT_ENABLE)</span> |
11. Time Management Interfaces
| Function | Interface Function |
|---|---|
| Get System Clock Tick Count | <span>tx_time_get()</span> |
| Set System Clock Tick Count | <span>tx_time_set()</span> |
| Sleep for a Certain Number of Ticks | <span>tx_thread_sleep()</span> |
| Time Conversion (No Direct API, Requires Macro Definition) |
12. Error Handling and Callbacks (Advanced Usage)
| Function | Interface Function |
|---|---|
| Register Thread Delete Callback | <span>tx_thread_delete_notify()</span> |
| Register Thread Termination Callback | <span>tx_thread_terminate_notify()</span> |
| Error Handling Hook | User Implemented <span>_tx_application_define()</span> or Custom Error Function |
Below is a brief usage example for each interface to help you quickly understand its purpose.
✅ 1. Thread Management
| Interface Function | Example Description |
|---|---|
<span>tx_thread_create</span> |
Create a thread |
TX_THREAD my_thread; // Thread handle
ULONG thread_stack[1024]; // Thread stack space
void my_thread_entry(ULONG input) { while(1); } // Thread function
tx_thread_create(&my_thread, "My Thread", my_thread_entry, 0,
thread_stack, sizeof(thread_stack),
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
| <span>tx_thread_delete</span> | Delete thread |
tx_thread_delete(&my_thread);
| <span>tx_thread_suspend</span> | Suspend thread |
tx_thread_suspend(&my_thread);
| <span>tx_thread_resume</span> | Resume thread |
tx_thread_resume(&my_thread);
✅ 2. Semaphore Management
| Interface Function | Example Description |
|---|---|
<span>tx_semaphore_create</span> |
Create semaphore |
TX_SEMAPHORE sem;
tx_semaphore_create(&sem, "MySem", 1);
| <span>tx_semaphore_get</span> | Get semaphore |
tx_semaphore_get(&sem, TX_WAIT_FOREVER);
| <span>tx_semaphore_put</span> | Release semaphore |
tx_semaphore_put(&sem);
| <span>tx_semaphore_delete</span> | Delete semaphore |
tx_semaphore_delete(&sem);
✅ 3. Mutex Management
| Interface Function | Example Description |
|---|---|
<span>tx_mutex_create</span> |
Create mutex |
TX_MUTEX mutex;
tx_mutex_create(&mutex, "MyMutex", TX_INHERIT);
| <span>tx_mutex_get</span> | Get mutex |
tx_mutex_get(&mutex, TX_WAIT_FOREVER);
| <span>tx_mutex_put</span> | Release mutex |
tx_mutex_put(&mutex);
| <span>tx_mutex_delete</span> | Delete mutex |
tx_mutex_delete(&mutex);
✅ 4. Queue Management
| Interface Function | Example Description |
|---|---|
<span>tx_queue_create</span> |
Create queue |
TX_QUEUE queue;
ULONG queue_area[10];
tx_queue_create(&queue, "MyQueue", TX_1_ULONG, queue_area, sizeof(queue_area));
| <span>tx_queue_send</span> | Send message |
ULONG msg = 0x12345678;
tx_queue_send(&queue, &msg, TX_NO_WAIT);
| <span>tx_queue_receive</span> | Receive message |
ULONG recv_msg;
tx_queue_receive(&queue, &recv_msg, TX_WAIT_FOREVER);
| <span>tx_queue_delete</span> | Delete queue |
tx_queue_delete(&queue);
✅ 5. Event Flags Management
| Interface Function | Example Description |
|---|---|
<span>tx_event_flags_create</span> |
Create event flags |
TX_EVENT_FLAGS_GROUP event_flags;
tx_event_flags_create(&event_flags, "MyFlags");
| <span>tx_event_flags_set</span> | Set event flags |
tx_event_flags_set(&event_flags, 0x01, TX_OR);
| <span>tx_event_flags_get</span> | Wait for event flags |
ULONG actual_flags;
tx_event_flags_get(&event_flags, 0x01, TX_OR_CLEAR, &actual_flags, TX_WAIT_FOREVER);
| <span>tx_event_flags_delete</span> | Delete event flags |
tx_event_flags_delete(&event_flags);
✅ 6. Timer Management
| Interface Function | Example Description |
|---|---|
<span>tx_timer_create</span> |
Create timer |
TX_TIMER timer;
void timer_callback(ULONG input) { /* Callback handling */ }
tx_timer_create(&timer, "MyTimer", timer_callback, 0,
100, 100, TX_AUTO_ACTIVATE);
| <span>tx_timer_activate</span> | Activate timer |
tx_timer_activate(&timer);
| <span>tx_timer_deactivate</span> | Deactivate timer |
tx_timer_deactivate(&timer);
| <span>tx_timer_delete</span> | Delete timer |
tx_timer_delete(&timer);
✅ 7. Block Pool Management
| Interface Function | Example Description |
|---|---|
<span>tx_block_pool_create</span> |
Create memory block pool |
TX_BLOCK_POOL pool;
CHAR memory[1000];
tx_block_pool_create(&pool, "MyPool", 100, memory, sizeof(memory));
| <span>tx_block_allocate</span> | Allocate memory block |
void *block;
tx_block_allocate(&pool, &block, TX_WAIT_FOREVER);
| <span>tx_block_release</span> | Release memory block |
tx_block_release(block);
| <span>tx_block_pool_delete</span> | Delete memory block pool |
tx_block_pool_delete(&pool);
✅ 8. System Control and Information Retrieval
| Interface Function | Example Description |
|---|---|
<span>tx_kernel_enter()</span> |
Start ThreadX system |
int main(void)
{
// After initializing various components
tx_kernel_enter();
}
| <span>tx_thread_sleep(ticks)</span> | Current thread sleeps |
tx_thread_sleep(100); // Sleep for 100 clock ticks
| <span>tx_time_get()</span> | Get system clock tick count |
ULONG ticks = tx_time_get();
For detailed reference on each API’s parameters and macro definitions, it is recommended to consult the official documentation “ThreadX User Guide” or check the example projects in the corresponding chip SDK.
Finally, welcome to follow and communicate, I am engaged in medical device R&D!!!

Please open in WeChat client