𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

The Design and Implementation of the RT-Thread Operating System

✍ Scribed by Qiu Yi, Xiong Puxiang, Tianlong Zhu


Publisher
CRC Press
Year
2020
Tongue
English
Leaves
413
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Since the release of V0.01 in 2006, to the present V4.0 version, RT-Thread has developed a reputation among developers for its open source strategy. RT-Thread has gained a large following among members of the embedded open source community in China with hundreds of thousands of enthusiasts. RT-Thread is widely used in energy, automotive, medical, consumer electronics, among other applications, making it a mature and stable open source embedded operating system.

The purpose of RT-Thread RTOS Design and Implementation is to create an easy learning curve for mastering RT-Thread, so that more developers can participate in the development of RT-Thread and work together to create an open source, tiny, and beautiful Internet of Things operating system. The book’s first part introduces the RT-Thread kernel and starts with an overview of RT-Thread before covering thread management, clock management, inter-thread synchronization, inter-thread communication, memory management, and interrupt management. The second part begins with RT-Thread kernel porting and explains how to port RT-Thread to a hardware board to run it. The second part also introduces RT-Thread components and discusses the Env development environment, FinSH console, device management, and network framework. Additional topics covered include:

  • The I/O device framework
  • Virtual file systems
  • Peripheral interfaces
  • Devices including the PIN device, UART device, and ADC device, among others.

Each chapter features code samples, as well as helpful tables and graphs, so you can practice as you learn as well as perform your own experiments.

✦ Table of Contents


Cover
Half Title
Title Page
Copyright Page
Contents
Preface
Acknowledgments
Authors
Chapter 1: Embedded Real-Time Operating System
Embedded System
Real-Time System
Soft Real Time and Hard Real Time
Embedded Real-Time Operating System
Mainstream Embedded Real-Time Operating System
Trend of Development
Chapter Summary
Chapter 2: RT-Thread Introduction
RT-Thread Overview
License Agreement
RT-Thread Architecture
Access to RT-Thread
License
Get the Source Code
Getting Started
First Glance at RT-Thread
LED Sample
Chapter Summary
Chapter 3: Kernel Basics
Introduction to RT-Thread Kernel
Thread Scheduling
Clock Management
Synchronization Between Threads
Inter-Thread Communication
Memory Management
I/O Device Management
RT-Thread Startup Process
RT-Thread Program Memory Distribution
RT-Thread Automatic Initialization Mechanism
RT-Thread Kernel Object Model
Static and Dynamic Objects
Kernel Object Management Structure
Object Control Block
Kernel Object Management
Initialization Object
Detach Object
Allocate Object
Delete Object
Identify Objects
RT-Thread Kernel Configuration Example
Common Macro Definition Description
Chapter Summary
Chapter 4: Thread Management
Thread Management Features
Working Mechanism of Thread
Thread Control Block
Important Attributes of Thread
Thread Stack
Thread State
Thread Priority
Time Slice
Thread Entry Function
Thread Error Code
Switching Thread State
System Thread
Idle Thread
Main Thread
Thread Management
Create and Delete Thread
Initialize and Detach Thread
Start Thread
Obtaining Current Thread
Making Thread Release Processor Resources
Thread Sleep
Suspend and Resume Thread
Control Thread
Set and Delete Idle Hooks
Set the Scheduler Hook
Thread Application Sample
Create Thread Sample
Thread Time Slice Round-Robin Scheduling Sample
Thread Scheduler Hook Sample
Chapter Summary
Chapter 5: Clock Management
Clock Tick (OS Tick)
Clock Tick Implementation
Obtain a Clock Tick
Timer Management
RT-Thread Timer Introduction
HARD_TIMER Mode
SOFT_TIMER Mode
Timer Working Mechanism
Timer Control Block
Timer Skip List Algorithm
Timer Management
Create and Delete a Timer
Initialize and Detach a Timer
Start and Stop a Timer
Control Timer
Timer Application Sample
High-Precision Delay
Chapter Summary
Chapter 6: Inter-Thread Synchronization
Semaphore
Semaphore Working Mechanism
Semaphore Control Block
Semaphore Management
Create and Delete a Semaphore
Initialize and Detach a Semaphore
Obtain Semaphore
Obtain Semaphore without Waiting
Release Semaphore
Semaphore Application Sample
Semaphore Usage Scenario
Thread Synchronization
Lock
Synchronization between Thread and Interrupt
Resource Count
Mutex
Mutex Working Mechanism
Mutex Control Block
Mutex Management
Create and Delete a Mutex
Initialize and Detach a Mutex
Obtain Mutex
Release Mutex
Mutex Application Sample
Occasions to Use Mutex
Event
Event Set Working Mechanism
Event Set Control Block
Event Set Management
Create And Delete an Event Set
Initialize And Detach an Event Set
Send an Event
Receive an Event
Event Set Application Sample
Occasions to Use an Event Set
Chapter Summary
Chapter 7: Inter-Thread Communication
Mailbox
Mailbox Working Mechanism
Mailbox Control Block
Management of Mailbox
Create and Delete a Mailbox
Initialize and Detach a Mailbox
Send Mail
Send Mails with Waiting
Receive Mails
Mailbox Usage Sample
Occasions to Use Mailbox
Message Queue
Message Queue Working Mechanism
Message Queue Control Block
Management of Message Queue
Create and Delete a Message Queue
Initialize and Detach a Message Queue
Send a Message
Send an Emergency Message
Receive a Message
Message Queue Application Example
Occasions To Use Message Queue
Sending Messages
Synchronizing Messages
Signal
Signal Working Mechanism
Management of Signal
Install a Signal
Block a Signal
Unblock a Signal
Send Signals
Wait for a Signal
Signal Application Example
Chapter Summary
Chapter 8: Memory Management
Memory Management Features
Memory Heap
Small Memory Management Algorithm
Slab Management Algorithm
Memory Allocation
Memory Release
Memheap Management Algorithm
Memory Heap Configuration and Initialization
Memory Heap Management
Allocate and Release a Memory Block
Reallocate a Memory Block
Allocate Multiple Memory Blocks
Set the Memory Hook Function
Memory Heap Management Application Example
Memory Pool
How a Memory Pool Works
Memory Pool Control Block
Memory Block Allocation Mechanism
Memory Pool Management
Create and Delete a Memory Pool
Initialize and Detach a Memory Pool
Allocate and Release a Memory Block
Memory Pool Application Example
Chapter Summary
Chapter 9: Interrupt Management
Cortex-M CPU Architecture Foundation
Introduction to Register
Operating Scheme and Privilege Level
Nested Vectored Interrupt Controller
PendSV System Call
RT-Thread Interruption Mechanism
Interrupt Vector Table
Interrupt Processing
Interrupt Preamble
User Interrupt Service Routine
Interrupt Follow-up Procedure
Interrupt Nesting
Interrupt Stack
Processing of the Bottom Half of the Interruption
RT-Thread Interrupt Management Interface
Mount Interrupt Service Routine
Interrupt Source Management
Enable and Disable Global Interrupt
Interrupt Notification
Interrupt and Polling
Global Interrupt Usage Example
Chapter Summary
Chapter 10: Kernel Porting
CPU Architecture Porting
Implement Global Interrupt Enable/Disable
Disable Global Interrupt
Enable Global Interrupt
Implement Thread Stack Initialization
Implement Context Switching
Implement rt_hw_context_switch_to()
Implement rt_hw_context_switch()/rt_hw_context_switch_interrupt()
Implement PendSV Interrupt
Implement OS Tick
BSP Porting
Kernel Porting Sample
Prepare for the Bare Metal Project
Build the RT-Thread Project
Implement Clock Management
Implement Console Output
Implement Dynamic Heap Memory Management
Port to More Development Boards
Chapter Summary
Chapter 11: Env-Assisted Development Environment
Env Introduction
Env Features
Compiling and Construction
Build Project Framework
Generate a New Project
Compile Project
Graphical System Configuration
Package Management
Upgrade Local Package Information
Download, Update, and Delete Packages
QEMU Simulator-Assisted Development
Example of Building a Project with Env
Register Env to the Right-Click Menu
Build a Project Framework
Modify the Template Project
Configure the Project
Generate the Project
Run and Verify
Build More MDK Projects
Create a Peripheral Example Project
Configure Device Drivers
Configure the Peripheral Example Software Package
Download the Software Package
Generate the Project
Create a File System Example Project
Configure to Enable DFS Components
Configure the File System Example Package
Download the Software Package
Generate the Project
Create a Network Example Project
Configure to Enable the Network Component
Configure the Network Example Software Package
Download the Software Package
Generate the Project
Chapter Summary
Chapter 12: FinSH Console
Introduction
Traditional Command Line Mode
C Language Interpreter Mode
Built-In Commands
Display Thread Status
Display Semaphore Status
Display Event Status
Display Mutex Status
Display Mailbox Status
Display Message Queue Status
Display Memory Pool Status
Display Timer Status
Display Device Status
Display Dynamic Memory Status
User-Defined FinSH Command
User-Defined MSH Command
User-Defined C-Style Command and Variable
User-Defined Command with Alias
Configuration
Application Examples
MSH Command without Argument
MSH Command with Arguments
Chapter Summary
Chapter 13: I/O Device Framework
I/O Device Introduction
I/O Device Framework
I/O Device Model
I/O Device Type
Create and Register the I/O Device
Access I/O Devices
Find Device
Initialize Device
Open and Close the Device
Control Device
Read and Write Device
Data Transceiving and Callback
Access Device Sample
Chapter Summary
Chapter 14: General Peripheral Interface
UART Device Driver
UART Device Management
Create and Register the UART Device
Access UART Device
Example of Using the UART Device
Pin Device Driver
Pin Device Management
Create and Register the PIN Device
Access the PIN Device
Set Input/Output Mode
Set Output Level
Get Input Level
Set Interrupt Callback Function
Enable/Disable Interrupt
Unset Interrupt Callback Function
Example of Using a PIN Device
SPI Device Driver
SPI Device Management
Create and Register the SPI Bus Device
Create and Mount the SPI Slave Device
Configure the SPI Slave Device
Access the SPI Slave Device
Transfer Data Chain
Transfer Data
Transmit Data
Receive Data
Transmit Two Data Segments
Transmit and Then Receive Data Segments
Other Utilities
Acquire SPI Bus
Set CS Signal
Append Data to the Chain
Clear CS Signal
Release SPI Bus
Example of Using the SPI Device
I2C Device Driver
I2C Device Management
Create and Register the I2C Bus Device
Access the I2C Bus
Example of Using an I2C Device
Demo Projects
PIN Device Demo Project
SPI Device Demo Project
I2C Device Demo Project
UART Device Demo Project
Chapter Summary
Chapter 15: Virtual File System
An Introduction to DFS
The Architecture of DFS
POSIX Interface Layer
Virtual File System Layer
Device Abstraction Layer
Mount Management
Initialize the DFS Component
Registered File System
Register a Storage Device as a Block Device
Format the File System
Mount the File System
Unmount a File System
Document Management
Open and Close Files
Read and Write Data
Rename
Get Status
Delete Files
Synchronize File Data to Storage Devices
Query File System–Related Information
Monitor I/O Device Status
Directory Management
Create and Delete Directories
Open and Close the Directory
Read a Directory
Get the Read Position of the Directory Stream
Set the Location to Read the Directory Next Time
Reset the Position of the Reading Directory to the Beginning
DFS Configuration Options
DFS Application Example
Preparation
Hardware Preparation
Software Preparation
Compile and Run
Formatting the File System
FinSH Command
Read and Write File Examples
An Example of Changing the File Name
Get File Status Example
Create a Directory Example
Read Directory Example
An Example of Setting the Location of the Read Directory
Chapter Summary
Chapter 16: Network Framework
TCP/IP Introduction to Network Protocols
OSI Reference Model
TCP/IP Reference Model
Difference between TCP/IP Reference Model and OSI Reference Model
IP Address
Subnet Mask
MAC Address
Introduction to the Network Framework of RT-Thread
Network Framework Workflow
Register the Network Protocol Cluster
Network Data Receiving Process
Network Data Sending Process
Network Socket Programming
TCP Socket Communication Process
UDP Socket Communication Process
Create a Socket
Binding Socket
Establishing a TCP Connection
Listening Socket
Accept the Connection
Establish Connection
Data Transmission
TCP Data Transmission
TCP Data Reception
UDP Data Transmission
UDP Data Reception
Close the Network Connection
Network Function Configuration
Network Application Example
Preparation
Hardware Preparation
Software Preparation
Compile and Run
View the Ip Address
Ping Network Test
TCP Client Example
UDP Client Example
Chapter Summary
Appendix A: β€œMenuconfig” Options
Appendix B: SCons
Appendix C: Getting Started with QEMU (Ubuntu)
Appendix D: Getting Started with RT-Thread Studio (Windows)
Index


πŸ“œ SIMILAR VOLUMES


The Design and Implementation of the RT-
✍ Qiu Yi, Xiong Puxiang, Tianlong Zhu πŸ“‚ Library πŸ“… 2020 πŸ› Auerbach Publications 🌐 English

<p>Since the release of V0.01 in 2006, to the present V4.0 version, RT-Thread has developed a reputation among developers for its open source strategy. RT-Thread has gained a large following among members of the embedded open source community in China with hundreds of thousands of enthusiasts. RT-Th

Design and Implementation of the MTX Ope
✍ K. C. Wang (auth.) πŸ“‚ Library πŸ“… 2015 πŸ› Springer International Publishing 🌐 English

<p><p>This course-tested textbook describes the design and implementation of operating systems, and applies it to the MTX operating system, a Unix-like system designed for Intel x86 based PCs. Written in an evolutional style, theoretical and practical aspects of operating systems are presented as th

The Design and Implementation of the Fre
✍ McKusick, Marshall Kirk;Neville-Neil, George V πŸ“‚ Library πŸ“… 2004 πŸ› Addison-Wesley Professional 🌐 English

This title provides a concise overview of FreeBSD's design and implementation. While explaining key design decisions, it details the concepts, data structures, and algorithms used in implementing the systems facilities. It is both a practical reference and an in-depth study of a contemporary, portab

The Design and Implementation of the Fre
✍ Marshall Kirk McKusick, George V. Neville-Neil πŸ“‚ Library πŸ“… 2004 πŸ› Addison-Wesley Professional 🌐 English

As in earlier Addison-Wesley books on the UNIX-based BSD operating system, Kirk McKusick and George Neville-Neil deliver here the most comprehensive, up-to-date, and authoritative technical information on the internal structure of open source FreeBSD. Readers involved in technical and sales support

The Design and Implementation of the Fre
✍ Marshall Kirk McKusick, George V. Neville-Neil, Robert N.M. Watson πŸ“‚ Library πŸ“… 2014 πŸ› Addison-Wesley Professional 🌐 English

The most complete, authoritative technical guide to the FreeBSD kernel’s internal structure has now been extensively updated to cover all major improvements between Versions 5 and 11. Approximately one-third of this edition’s content is completely new, and another one-third has been extensively rewr