ThreadX User Guide Ver.5
Contents
Figures
About This Guide
Organization
Guide Conventions
ThreadX Data Types
Customer Support Center
Latest Product Information
What We Need From You
Where to Send Comments About This Guide
1 Introduction to ThreadX
ThreadX Unique Features
picokernel™ Architecture
ANSI C Source Code
Advanced Technology
Not A Black Box
The RTOS Standard
Safety Certifications
TÜV Certification
MISRA C Compliant
UL Certification
Certification Pack
Embedded Applications
Real-time Software
Multitasking
Tasks vs. Threads
ThreadX Benefits
Improved Responsiveness
Software Maintenance
Increased Throughput
Processor Isolation
Dividing the Application
Ease of Use
Improve Time-to-market
Protecting the Software Investment
2 Installation and Use of ThreadX
Host Considerations
Target Considerations
Product Distribution
ThreadX Installation
Using ThreadX
Small Example System
Troubleshooting
Configuration Options
Smallest Configuration
Fastest Configuration
Global Time Source
Detailed Configuration Options
ThreadX Version ID
3 Functional Components of ThreadX
Execution Overview
Initialization
Thread Execution
Interrupt Service Routines (ISR)
Application Timers
Memory Usage
Static Memory Usage
Dynamic Memory Usage
Initialization
System Reset Vector
Development Tool Initialization
main Function
tx_kernel_enter
Application Definition Function
Interrupts
Thread Execution
Thread Execution States
Thread Entry/Exit Notification
Thread Priorities
Thread Scheduling
Round-robin Scheduling
Time-Slicing
Preemption
Preemption- Threshold™
Priority Inheritance
Thread Creation
Thread Control Block TX_THREAD
Currently Executing Thread
Thread Stack Area
Memory Pitfalls
Optional Run-time Stack Checking
Reentrancy
Thread Priority Pitfalls
Priority Overhead
Run-time Thread Performance Information
Debugging Pitfalls
Message Queues
Creating Message Queues
Message Size
Message Queue Capacity
Queue Memory Area
Thread Suspension
Queue Send Notification
Queue Event- chaining™
Run-time Queue Performance Information
Queue Control Block TX_QUEUE
Message Destination Pitfall
Counting Semaphores
Mutual Exclusion
Event Notification
Creating Counting Semaphores
Thread Suspension
Semaphore Put Notification
Semaphore Event- chaining™
Run-time Semaphore Performance Information
Semaphore Control Block TX_SEMAPHORE
Deadly Embrace
Priority Inversion
Mutexes
Mutex Mutual Exclusion
Creating Mutexes
Thread Suspension
Run-time Mutex Performance Information
Mutex Control Block TX_MUTEX
Deadly Embrace
Priority Inversion
Event Flags
Creating Event Flags Groups
Thread Suspension
Event Flags Set Notification
Event Flags Event- chaining™
Run-time Event Flags Performance Information
Event Flags Group Control Block TX_EVENT_FLAGS_GROUP
Memory Block Pools
Creating Memory Block Pools
Memory Block Size
Pool Capacity
Pool’s Memory Area
Thread Suspension
Run-time Block Pool Performance Information
Memory Block Pool Control Block TX_BLOCK_POOL
Overwriting Memory Blocks
Memory Byte Pools
Creating Memory Byte Pools
Pool Capacity
Pool’s Memory Area
Thread Suspension
Run-time Byte Pool Performance Information
Memory Byte Pool Control Block TX_BYTE_POOL
Nondeterministic Behavior
Overwriting Memory Blocks
Application Timers
Timer Intervals
Timer Accuracy
Timer Execution
Creating Application Timers
Run-time Application Timer Performance Information
Application Timer Control Block TX_TIMER
Excessive Timers
Relative Time
Interrupts
Interrupt Control
ThreadX Managed Interrupts
ISR Template
High-frequency Interrupts
Interrupt Latency
4 Description of ThreadX Services
tx_block_allocate
tx_block_pool_create
tx_block_pool_delete
tx_block_pool_info_get
tx_block_pool_performance_info_get
tx_block_pool_performance_system_info_get
tx_block_pool_prioritize
tx_block_release
tx_byte_allocate
tx_byte_pool_create
tx_byte_pool_delete
tx_byte_pool_info_get
tx_byte_pool_performance_info_get
tx_byte_pool_performance_system_info_get
tx_byte_pool_prioritize
tx_byte_release
tx_event_flags_create
tx_event_flags_delete
tx_event_flags_get
tx_event_flags_info_get
tx_event_flags_performance info_get
tx_event_flags_performance_system_info_get
tx_event_flags_set
tx_event_flags_set_notify
tx_interrupt_control
tx_mutex_create
tx_mutex_delete
tx_mutex_get
tx_mutex_info_get
tx_mutex_performance_info_get
tx_mutex_performance_system_info_get
tx_mutex_prioritize
tx_mutex_put
tx_queue_create
tx_queue_delete
tx_queue_flush
tx_queue_front_send
tx_queue_info_get
tx_queue_performance_info_get
tx_queue_performance_system_info_get
tx_queue_prioritize
tx_queue_receive
tx_queue_send
tx_queue_send_notify
tx_semaphore_ceiling_put
tx_semaphore_create
tx_semaphore_delete
tx_semaphore_get
tx_semaphore_info_get
tx_semaphore_performance_info_get
tx_semaphore_performance_system_info_get
tx_semaphore_prioritize
tx_semaphore_put
tx_semaphore_put_notify
tx_thread_create
tx_thread_delete
tx_thread_entry_exit_notify
tx_thread_identify
tx_thread_info_get
tx_thread_performance_info_get
tx_thread_performance_system_info_get
tx_thread_preemption_change
tx_thread_priority_change
tx_thread_relinquish
tx_thread_reset
tx_thread_resume
tx_thread_sleep
tx_thread_stack_error_notify
tx_thread_suspend
tx_thread_terminate
tx_thread_time_slice_change
tx_thread_wait_abort
tx_time_get
tx_time_set
tx_timer_activate
tx_timer_change
tx_timer_create
tx_timer_deactivate
tx_timer_delete
tx_timer_info_get
tx_timer_performance_info_get
tx_timer_performance_system_info_get
5 Device Drivers for ThreadX
Device Driver Introduction
Driver Functions
Driver Initialization
Driver Control
Driver Access
Driver Input
Driver Output
Driver Interrupts
Driver Status
Driver Termination
Simple Driver Example
Simple Driver Initialization
Simple Driver Input
Simple Driver Output
Simple Driver Shortcomings
Advanced Driver Issues
I/O Buffering
Circular Byte Buffers
Circular Buffer Input
Circular Output Buffer
Buffer I/O Management
TX_IO_BUFFER
Buffered I/O Advantage
Buffered Driver Responsibilities
Interrupt Management
Thread Suspension
6 Demonstration System for ThreadX
Overview
Application Define
Initial Execution
Thread 0
Thread 1
Thread 2
Threads 3 and 4
Thread 5
Threads 6 and 7
Observing the Demonstration
Distribution file: demo_threadx.c
A ThreadX API Services
Entry Function
Block Memory Services
Byte Memory Services
Event Flags Services
Interrupt Control
Mutex Services
Queue Services
Semaphore Services
Thread Control Services
Time Services
Timer Services
B ThreadX Constants
Alphabetic Listings
Listing by Value
C ThreadX Data Types
TX_BLOCK_POOL
TX_BYTE_POOL
TX_EVENT_FLAGS_GROUP
TX_MUTEX
TX_QUEUE
TX_SEMAPHORE
TX_THREAD
TX_TIMER
TX_TIMER_INTERNAL
D ASCII Character Codes
Index