Cover Page
Copyright Page
Copyright Page
Dedication
Dedication
Preface
Preface
Embedded and Real-time Systems
Embedded and Real-time Systems
Introduction
What is an Embedded System?
Characteristics of Embedded Systems
Real-time Systems
Real-time Operating Systems and Real-time Kernels
Processes, Tasks, and Threads
Architecture of Real-time Systems
Embedded Systems Development
Key Terms and Phrases
First Look at a System Using an RTOS
First Look at a System Using an RTOS
Operating Environment
Installation of the ThreadX Demonstration System
Sample System with Two Threads
Creating the ThreadX Objects
Compiling and Executing the Sample System
Analysis of the System and the Resulting Output
Listing of 02_sample_system.c
Key Terms and Phrases
Problems
RTOS Concepts and Definitions
RTOS Concepts and Definitions
Introduction
Priorities
Ready Threads and Suspended Threads
Preemptive, Priority-Based Scheduling
Round-Robin Scheduling
Determinism
Kernel
RTOS
Context Switch
Time-Slice
Interrupt Handling
Thread Starvation
Priority Inversion
Priority Inheritance
Preemption-Threshold
Key Terms and Phrases
Problems
RTOS Building Blocks for System Development
RTOS Building Blocks for System Development
Introduction
Defining Public Resources
ThreadX Data Types
Thread
Memory Pools
Application Timer
Mutex
Counting Semaphore
Event Flags Group
Message Queue
Summary of Thread Synchronization and Communication Components
Key Terms and Phrases
Problems
The Thread—The Essential Component
The Thread—The Essential Component
Introduction
Thread Control Block
Summary of Thread Services
Thread Creation
Thread Deletion
Identify Thread
Get Thread Information
Preemption-Threshold Change
Priority Change
Relinquish Control
Resume Thread Execution
Thread Sleep
Suspend Thread Execution
Terminate Application Thread
Time-Slice Change
Abort Thread Suspension
Thread Notification Services
Execution Overview
Thread States
Thread Design
Minimize the Number of Threads
Choose Priorities Carefully
Minimize the Number of Priorities
Consider Preemption-Threshold
Consider Priority Inheritance
Consider Round-Robin Scheduling
Consider Time-Slicing
Thread Internals
Overview
Key Terms and Phrases
Problems
Mutual Exclusion Challenges and Considerations
Mutual Exclusion Challenges and Considerations
Introduction
Protecting a Critical Section
Providing Exclusive Access to Shared Resources
Mutex Control Block
Summary of Mutex Services
Creating a Mutex
Deleting a Mutex
Obtaining Ownership of a Mutex
Retrieving Mutex Information
Prioritizing the Mutex Suspension List
Releasing Ownership of a Mutex
Avoiding the Deadly Embrace
Sample System Using a Mutex to Protect Critical Sections
Output Produced by Sample System
Listing for 06_sample_system.c
Mutex Internals
Overview
Key Terms and Phrases
Problems
Memory Management: Byte Pools and Block Pools
Memory Management: Byte Pools and Block Pools
Introduction
Summary of Memory Byte Pools
Memory Byte Pool Control Block
Pitfalls of Memory Byte Pools
Summary of Memory Byte Pool Services
Creating a Memory Byte Pool
Allocating from a Memory Byte Pool
Deleting a Memory Byte Pool
Retrieving Memory Byte Pool Information
Prioritizing a Memory Byte Pool Suspension List
Releasing Memory to a Byte Pool
Memory Byte Pool Example—Allocating Thread Stacks
Memory Byte Pool Internals
Summary of Memory Block Pools
Memory Block Pool Control Block
Summary of Memory Block Pool Services
Creating a Memory Block Pool
Allocating a Memory Block Pool
Deleting a Memory Block Pool
Retrieving Memory Block Pool Information
Prioritizing a Memory Block Pool Suspension List
Releasing a Memory Block
Memory Block Pool Example—Allocating Thread Stacks
Memory Block Pool Internals
Overview and Comparison
Key Terms and Phrases
Problems
Internal System Clock and Application Timers
Internal System Clock and Application Timers
Introduction
Internal System Clock Services
Application Timer Control Block
Summary of Application Timer Services
Creating an Application Timer
Activating an Application Timer
Changing an Application Timer
Deactivating an Application Timer
Deleting an Application Timer
Retrieving Application Timer Information
Sample System Using Timers to Measure Thread Performance
Listing for 8_sample_system.c
Overview
Key Terms and Phrases
Problems
Event Notification and Synchronization with Counting Semaphores
Event Notification and Synchronization with Counting Semaphores
Introduction
Counting Semaphore Control Block
Avoiding Deadly Embrace
Avoiding Priority Inversion
Summary of Counting Semaphore Services
Creating a Counting Semaphore
Deleting a Counting Semaphore
Getting an Instance of a Counting Semaphore
Retrieving Information about Counting Semaphores
Prioritizing a Counting Semaphore Suspension List
Placing an Instance in a Counting Semaphore
Placing an Instance in a Semaphore Using a Ceiling
Semaphore Notification and Event-Chaining
Comparing a Counting Semaphore with a Mutex
Sample System Using a Binary Semaphore in Place of a Mutex
Listing for 9a_sample_system.c
Sample System Using a Counting Semaphore in a Producer-Consumer Application
Listing for 9b_sample_system.c
Counting Semaphore Internals
Overview
Key Terms and Phrases
Problems
Synchronization of Threads Using Event Flags Groups
Synchronization of Threads Using Event Flags Groups
Introduction
Event Flags Group Control Block
Summary of Event Flags Group Control Services
Creating an Event Flags Group
Deleting an Event Flags Group
Getting Event Flags from an Event Flags Group
Retrieving Information about an Event Flags Group
Setting Event Flags in an Event Flags Group
Event Flags Group Notification and Event-Chaining
Sample System Using an Event Flags Group to Synchronize Two Threads
Listing for 10_sample_system.c
Event Flags Group Internals
Overview
Key Terms and Phrases
Problems
Thread Communication with Message Queues
Thread Communication with Message Queues
Introduction
Message Queue Control Block
Summary of Message Queue Services
Creating a Message Queue
Sending a Message to a Message Queue
Receiving a Message from a Message Queue
Deleting a Message Queue
Flushing the Contents of a Message Queue
Sending a Message to the Front of a Message Queue
Retrieving Message Queue Information
Prioritizing a Message Queue Suspension List
Message Queue Notification and Event-Chaining
Sample System Using a Message Queue for Interthread Communication
Listing for 11_sample_system.c
Message Queue Internals
Overview
Key Terms and Phrases
Problems
Advanced Topics
Advanced Topics
Introduction
Event-Chaining
Queue Event-Chaining
Semaphore Event-Chaining
Event Flags Group Event-Chaining
Sample System Using Event-Chaining
Listing for 12_sample_system.c
Run-Time Performance Metrics
Block Pool Performance Information
Byte Pool Performance Information
Event Flags Performance Information
Mutex Performance Information
Queue Performance Information
Semaphore Performance Information
Thread Performance Information
Timer Performance Information
Key Terms and Phrases
Case Study: Designing a Multithreaded System
Case Study: Designing a Multithreaded System
Introduction
Statement of Problem
Analysis of the Problem
Design of the System
Thread Design
Public Resources Design
Implementation
Listing of VAM System
Overview
Appendix A: Memory Block Pool Services
Appendix A: Memory Block Pool Services
Appendix B: Memory Byte Pool Services
Appendix B: Memory Byte Pool Services
Appendix C: Event Flags Group Services
Appendix C: Event Flags Group Services
Appendix D: Interrupt Control Service
Appendix D: Interrupt Control Service
Appendix E: Mutex Services
Appendix E: Mutex Services
Appendix F: Message Queue Services
Appendix F: Message Queue Services
Appendix G: Counting Semaphore Services
Appendix G: Counting Semaphore Services
Appendix H: Thread Services
Appendix H: Thread Services
Appendix I: Internal System Clock Services
Appendix I: Internal System Clock Services
Appendix J: Application Timer Services
Appendix J: Application Timer Services
Appendix K: ThreadX API
Appendix K: ThreadX API
Appendix L: ThreadX and the ARM Microprocessor
Appendix L: ThreadX and the ARM Microprocessor
Appendix M: ThreadX and the ColdFireMicroprocessor
Appendix M: ThreadX and the ColdFireMicroprocessor
Appendix N: ThreadX and the MIPS Microprocessor
Appendix N: ThreadX and the MIPS Microprocessor
Appendix O: ThreadX and the PowerPC Microprocessor
Appendix O: ThreadX and the PowerPC Microprocessor
Index
Index
A
B
C
D
E
F
G
H
I
K
L
M
N
O
P
Q
R
S
T
U
V
W