logo资料库

threadx用户手册.pdf

第1页 / 共326页
第2页 / 共326页
第3页 / 共326页
第4页 / 共326页
第5页 / 共326页
第6页 / 共326页
第7页 / 共326页
第8页 / 共326页
资料共326页,剩余部分请下载后查看
Contents
Figures
About This Guide
Organization
Guide Conventions
ThreadX Data Types
Customer Support Center
Where to Send Comments
Introduction to ThreadX
ThreadX Unique Features
picokernel™ Architecture
ANSI C Source Code
Not A Black Box
A Potential Standard
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
Installation and Use of ThreadX
Host Considerations
Target Considerations
Product Distribution
ThreadX Installation
Using ThreadX
Small Example System
Troubleshooting
Configuration Options
ThreadX Version ID
Functional Components of ThreadX
Execution Overview
Initialization
Initialization
Thread Execution
Interrupt Service Routines (ISR)
Application Timers
Memory Usage
Static Memory Usage
Dynamic Memory Usage
Initialization
System Reset
Development Tool Initialization
main
tx_kernel_enter
Application Definition Function
Interrupts
Thread Execution
Thread Execution States
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
Reentrancy
Thread Priority Pitfalls
Priority Overhead
Debugging Pitfalls
Message Queues
Creating Message Queues
Message Size
Message Queue Capacity
Queue Memory Area
Thread Suspension
Queue Control Block TX_QUEUE
Message Destination Pitfall
Counting Semaphores
Mutual Exclusion
Event Notification
Creating Counting Semaphores
Thread Suspension
Semaphore Control Block TX_SEMAPHORE
Deadly Embrace
Priority Inversion
Mutexes
Mutex Mutual Exclusion
Creating Mutexes
Thread Suspension
Mutex Control Block TX_MUTEX
Deadly Embrace
Priority Inversion
Event Flags
Creating Event Flag Groups
Thread Suspension
Event Flag 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
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
Memory Byte Pool Control Block TX_BYTE_POOL
Un-deterministic Behavior
Overwriting Memory Blocks
Application Timers
Timer Intervals
Timer Accuracy
Timer Execution
Creating Application Timers
Application Timer Control Block TX_TIMER
Excessive Timers
Relative Time
Interrupts
Interrupt Control
ThreadX Managed Interrupts
ISR Template
High-Frequency Interrupts
Interrupt Latency
Description of ThreadX Services
tx_block_allocate
tx_block_pool_create
tx_block_pool_delete
tx_block_pool_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_prioritize
tx_byte_release
tx_event_flags_create
tx_event_flags_delete
tx_event_flags_get
tx_event_flags_info_get
tx_event_flags_set
tx_interrupt_control
tx_mutex_create
tx_mutex_delete
tx_mutex_get
tx_mutex_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_prioritize
tx_queue_receive
tx_queue_send
tx_semaphore_create
tx_semaphore_delete
tx_semaphore_get
tx_semaphore_info_get
tx_semaphore_prioritize
tx_semaphore_put
tx_thread_create
tx_thread_delete
tx_thread_identify
tx_thread_info_get
tx_thread_preemption_change
tx_thread_priority_change
tx_thread_relinquish
tx_thread_resume
tx_thread_sleep
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
I/O Drivers for ThreadX
I/O 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
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.c
Internal Composition of ThreadX
ThreadX Design Goals
Simplicity
Scalability
High Performance
ThreadX ANSI C Library
System Include Files
System Entry
Application Definition
Software Components
ThreadX Components
Component Specification File
Component Initialization
Component Body Functions
Coding Conventions
ThreadX File Names
ThreadX Name Space
ThreadX Constants
ThreadX Struct and Typedef Names
ThreadX Member Names
ThreadX Global Data
ThreadX Local Data
ThreadX Function Names
Source Code Indentation
Comments
Initialization Component
TX_INI.H
TX_IHL.C
TX_IKE.C
TX_ILL.[S, ASM]
Thread Component
TX_THR.H
TX_TC.C
TX_TCR.[S,ASM]
TX_TCS.[S,ASM]
TX_TDEL.C
TX_TI.C
TX_TIC.[S,ASM]
TX_TIDE.C
TX_TIG.C
TX_TPC.[S,ASM]
TX_TPCH.C
TX_TPRCH.C
TX_TR.C
TX_TRA.C
TX_TREL.C
TX_TS.[S,ASM]
TX_TSA.C
TX_TSB.[S,ASM]
TX_TSE.C
TX_TSLE.C
TX_TSR.[S,ASM]
TX_TSUS.C
TX_TT.C
TX_TTO.C
TX_TTS.C
TX_TTSC.C
TX_TWA.C
TXE_TC.C
TXE_TDEL.C
TXE_TIG.C
TXE_TPCH.C
TXE_TRA.C
TXE_TREL.C
TXE_TRPC.C
TXE_TSA.C
TXE_TT.C
TXE_TTSC.C
TXE_TWA.C
Timer Component
TX_TIM.H
TX_TA.C
TX_TAA.C
TX_TD.C
TX_TDA.C
TX_TIMCH.C
TX_TIMCR.C
TX_TIMD.C
TX_TIMEG.C
TX_TIMES.C
TX_TIMI.C
TX_TIMIG.C
TX_TIMIN.[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te Memory Services
Block Memory Services
Event Flag Services
Interrupt Control
Message Queue Services
Semaphore Services
Mutex Services
Thread Control Services
Time Services
Timer Services
ThreadX Constants
Alphabetic Listings
Listing by Value
ThreadX Data Types
ThreadX Source Files
ThreadX C Include Files
ThreadX C Source Files
ThreadX Port Specific Assembly Language Files
ASCII Character Codes in HEX
ASCII Character Codes
Index
® the high-performance embedded kernel USER GUIDE Express Logic, Inc. 858-613-6640 Toll Free 888-THREADX FAX 858-613-6646 http://www.expresslogic.com
©1997-2002 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, and preemption-threshold 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 4.0b Express Logic, Inc.
Contents Figures 7 About This Guide 9 1 Guide Conventions 10 1 ThreadX Data Types 11 1 Customer Support Center 12 1 Introduction to ThreadX 13 1 ThreadX Unique Features 14 1 Embedded Applications 15 1 ThreadX Benefits 17 2 Installation and Use of ThreadX 21 1 Host Considerations 22 1 Target Considerations 22 1 Product Distribution 23 1 ThreadX Installation 24 1 Using ThreadX 25 1 Small Example System 26 1 Troubleshooting 28 1 Configuration Options 28 1 ThreadX Version ID 29 User Guide
4 ThreadX 3 Functional Components of ThreadX 31 1 Execution Overview 34 1 Memory Usage 36 1 Initialization 38 1 Thread Execution 40 1 Message Queues 55 1 Counting Semaphores 58 1 Mutexes 62 1 Event Flags 65 1 Memory Block Pools 67 1 Memory Byte Pools 69 1 Application Timers 73 1 Relative Time 75 1 Interrupts 75 4 Description of ThreadX Services 79 5 I/O Drivers for ThreadX 213 1 I/O Driver Introduction 214 1 Driver Functions 214 1 Simple Driver Example 216 1 Advanced Driver Issues 221 6 Demonstration System for ThreadX 229 1 Overview 230 1 Application Define 230 1 Thread 0 232 1 Thread 1 232 1 Thread 2 232 User Guide
Contents 5 1 Threads 3 and 4 233 1 Thread 5 233 1 Threads 6 and 7 234 1 Observing the Demonstration 234 1 Distribution file: demo.c 235 7 Internal Composition of ThreadX 241 1 ThreadX Design Goals 246 1 Software Components 248 1 Coding Conventions 250 1 Initialization Component 256 1 Thread Component 257 1 Timer Component 265 1 Queue Component 270 1 Semaphore Component 273 1 Mutex Component 275 1 Event Flag Component 278 1 Block Memory Component 280 1 Byte Memory Component 283 A ThreadX API Services 287 B ThreadX Constants 293 1 Alphabetic Listings 294 1 Listing by Value 295 C ThreadX Data Types 297 Express Logic, Inc.
6 ThreadX D ThreadX Source Files 303 1 ThreadX C Include Files 304 1 ThreadX C Source Files 304 1 ThreadX Port Specific Assembly Language Files 310 E ASCII Character Codes 311 1 ASCII Character Codes in HEX 312 Index 313 User Guide
Figures FIGURE 1. FIGURE 2. FIGURE 3. FIGURE 4. FIGURE 5. FIGURE 6. FIGURE 7. FIGURE 8. FIGURE 9. Template for Application Development 27 Types of Program Execution 35 Memory Area Example 37 Initialization Process 41 Thread State Transition 43 Typical Thread Stack 49 Stack Preset to 0xEFEF 51 Example of Suspended Threads 61 Simple Driver Initialization 218 FIGURE 10. Simple Driver Input 219 FIGURE 11. Simple Driver Output 220 FIGURE 12. Logic for Circular Input Buffer 222 FIGURE 13. Logic for Circular Output Buffer 223 FIGURE 14. I/O Buffer 224 FIGURE 15. Input-Output Lists 226 FIGURE 16. ThreadX File Header Example 255 User Guide
8 ThreadX User Guide
分享到:
收藏