1st Edition

Real-Time Embedded Multithreading Using ThreadX and MIPS

By Edward Lamie Copyright 2009
488 Pages
by CRC Press

484 Pages
by CRC Press

484 Pages
by CRC Press

Real-Time Embedded Multithreading Using ThreadX and MIPS contains the fundamentals of developing real-time operating systems and multithreading with all the new functionality of ThreadX Version 5. This MIPS edition covers all the new ThreadX 5 features, including real-time event-chaining, run-time performance metrics, and run-time stack analysis as

Preface

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

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

Introduction

Priorities

Ready Threads and Suspended Threads

Preemptive, Priority-Based Scheduling

Round-Robin Scheduling

Determination

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

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

Introduction to the MIPS Microprocessor

Introduction

History

Technical Features

MIPS Power Saving Support

Key Terms and Phrases

MIPS Exception Handling

Introduction

ThreadX Implantation of MIPS Exception Handling

Key Terms and Phrases

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

Thread Internals

Overview

Key Terms and Phrases

Problems

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 08_sample_system.c

Mutex Internals

Overview

Key Terms and Phrases

Problems

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 from 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 of Comparison

Key Terms and Phrases

Problems

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 10 sample system.c

Application Timer Internals

Overview

Key Terms and Phrases

Problems

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 11a_sample_system.c

Sample System Using a Counting Semaphore in a Producer-Consumer Application

Listing for 11b sample_system.c

Counting Semaphore Internals

Overview

Key Terms and Phrases

Problems

Synchronization of Thread 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 12 sample system.c

Event Flags Group Internals

Overview

Key Terms and Phrases

Problems

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 13 sample system.c

Message Queue Internals

Overview

Key Terms and Phrases

Problems

Case Study: Designing a Multithreaded System

Introduction

Statement of Problem

Analysis of the Problem

Design of the System

Implementation

Listing of VAM System

Overview

Appendices

Appendix A: Memory Block Pool Services

Appendix B: Memory Byte Block Pool Services

Appendix C: Event Flags Group Services

Appendix D: Interrupt Control Service

Appendix E: Mutex Services

Appendix F: Message Queue Services

Appendix G: Counting Semaphore Services

Appendix F: Thread Services

Appendix H: Internal System Clock Services

Appendix I: Internal System Clock Services

Appendix J: Application Timer Services

Appendix K: ThreadX API

Index

Biography

Edward L. Lamie is a Professor Emeritus of Computer Science. His areas of academic emphasis during his 31 years in higher education have been in the areas of software engineering and operating systems. He was also the founding chair of computer science departments at Central Michigan University and California State University, Stanislaus. Ed continues to teach occasional graduate-level courses and conducts hands-on RTOS training classes for Express Logic, Inc.