the high-performance embedded kernel
User Guide
Express Logic, Inc.
858.613.6640
Toll Free 888.THREADX
FAX 858.521.4259
http://www.expresslogic.com
®
Version 5.0
Express Logic, Inc.
©1997-2006 by Express Logic, Inc.
All rights reserved. This document and the associated ThreadX software are the sole property of
Express Logic, Inc. Each contains proprietary information of Express Logic, Inc. Reproduction or
duplication by any means of any portion of this document without the prior written consent of Express
Logic, Inc. is expressly forbidden.
Express Logic, Inc. reserves the right to make changes to the specifications described herein at any
time and without notice in order to improve design or reliability of ThreadX. The information in this
document has been carefully checked for accuracy; however, Express Logic, Inc. makes no warranty
pertaining to the correctness of this document.
Trademarks
ThreadX is a registered trademark of Express Logic, Inc., and picokernel, preemption-threshold, and
event-chaining are trademarks of Express Logic, Inc.
All other product and company names are trademarks or registered trademarks of their respective
holders.
Warranty Limitations
Express Logic, Inc. makes no warranty of any kind that the ThreadX products will meet the USER’s
requirements, or will operate in the manner specified by the USER, or that the operation of the
ThreadX products will operate uninterrupted or error free, or that any defects that may exist in the
ThreadX products will be corrected after the warranty period. Express Logic, Inc. makes no warranties
of any kind, either expressed or implied, including but not limited to the implied warranties of
merchantability and fitness for a particular purpose, with respect to the ThreadX products. No oral or
written information or advice given by Express Logic, Inc., its dealers, distributors, agents, or
employees shall create any other warranty or in any way increase the scope of this warranty, and
licensee may not rely on any such information or advice.
Part Number: 000-1001
Revision 5.0
User Guide
Contents
About This Guide 13
1 Organization 13
1 Guide Conventions 14
1 ThreadX Data Types 15
1 Customer Support Center 16
Latest Product Information 16
What We Need From You 16
Where to Send Comments About This Guide 17
1 Introduction to ThreadX 19
1 ThreadX Unique Features 20
picokernel™ Architecture 20
ANSI C Source Code 20
Advanced Technology 20
Not A Black Box 21
The RTOS Standard 22
1 Embedded Applications 22
Real-time Software 22
Multitasking 22
Tasks vs. Threads 23
1 ThreadX Benefits 23
Improved Responsiveness 24
Software Maintenance 24
Increased Throughput 24
Processor Isolation 25
Dividing the Application 25
Ease of Use 26
Improve
4 ThreadX
User Guide
Time-to-market 26
Protecting the Software Investment 26
2 Installation and Use of ThreadX 27
1 Host Considerations 28
1 Target Considerations 28
1 Product Distribution 29
1 ThreadX Installation 30
1 Using ThreadX 31
1 Small Example System 32
1 Troubleshooting 34
1 Configuration Options 34
1 ThreadX Version ID 40
3 Functional Components of ThreadX 41
1 Execution Overview 44
Initialization 44
Thread Execution 44
Interrupt Service Routines (ISR) 44
Initialization 45
Application Timers 46
1 Memory Usage 46
Static Memory Usage 46
Dynamic Memory Usage 48
1 Initialization 48
System Reset Vector 48
Development Tool Initialization 49
main Function 49
tx_kernel_enter 49
Application Definition Function 50
Interrupts 50
1 Thread Execution 50
Thread Execution States 52
Thread Entry/Exit Notification 54
Contents 5
Express Logic, Inc.
Thread Priorities 54
Thread Scheduling 55
Round-robin Scheduling 55
Time-Slicing 55
Preemption 56
Preemption-Threshold™ 56
Priority Inheritance 57
Thread Creation 57
Thread Control Block TX_THREAD 57
Currently Executing Thread 59
Thread Stack Area 59
Memory Pitfalls 62
Optional Run-time Stack Checking 62
Reentrancy 62
Thread Priority Pitfalls 63
Priority Overhead 64
Run-time Thread Performance Information 65
Debugging Pitfalls 66
1 Message Queues 67
Creating Message Queues 68
Message Size 68
Message Queue Capacity 68
Queue Memory Area 69
Thread Suspension 69
Queue Send Notification 70
Queue Event-chaining™ 70
Run-time Queue Performance Information 71
Queue Control Block TX_QUEUE 72
Message Destination Pitfall 72
1 Counting Semaphores 72
Mutual Exclusion 73
Event Notification 73
Creating Counting Semaphores 74
Thread Suspension 74
Semaphore Put Notification 74
Semaphore Event-chaining™ 75
Run-time Semaphore Performance Information 75
Semaphore Control Block TX_SEMAPHORE 76
Deadly Embrace 76
Priority Inversion 78