Data Types• Using C compiler primitive data types is not wise.. • RTOSes provide special data types.. Data Types cont’d• RTOS defines its own data types.. o Most RTOSes consist of a sing
Trang 1RTOS Building Blocks for System
Development
Trang 2About SwiftACT
• A Technology services startup company
o Under establishment
• Areas of specialties:
o Mobile telecommunication services development
o Embedded systems development
Trang 3About Me
• Graduated 2004
o ECE, ASU: 5 yrs distinction
• 5+ years in embedded systems development
Trang 4• Materials in this course is the property of Amr Ali Abdel-Naby
• Reproduction or transmission of the materials in any manner without the copyright owner permission is a law violation
Trang 7o Thread management APIs, Mutex management APIs…
Trang 9Defining Public Resources
• Some objects are public
o They can be accessed from any thread.
• Accessing a public object is not like owning it
o Mutex can be accessed from any thread A public object
o A mutex has only 1 owner at a time A private ownership
Trang 11Data Types
• Using C compiler primitive data types is not wise
o int, char, double…
• C code should be portable
• RTOSes provide special data types
o The wrap the C compiler primitive ones.
o They ensure compiler and architecture portability.
o In uCOS-II: INT8U, INT8, INT16U…
Trang 12Data Types cont’d
• RTOS defines its own data types
o To define its own objects
o In uCOS-II: OS_EVENT, OS_STK, OS_FLAG_GROUP…
Trang 14• Independent program segment
o Independent execution, independent processing
• Has its own stack
• Threads in the same process share the same address space
• Every process has at least 1 thread
o Most RTOSes consist of a single process and multiple threads.
Trang 15Thread cont’d
• Each thread has a Task Control Block (TCB)
• Every task is assigned a TCB when created
Trang 16Thread cont’d
• A TCB contains:
o Task’s priority
o Task’s state
o A pointer to the task’s top of stack
o Other task’s related data
• TCBs reside in RAM
Trang 18Memory Pools
• Memory Block Pool
o Fixed size based
o Used in most of RTOSes
• Memory Byte Pool
o Smallest size is byte
Trang 26Event Flag Group
• Event flag 1 bit
• Used for threads synchronization
• Event flag group group of flags
• Threads can operate on any
or all of the event flags
Trang 28Message Queue
• Used for thread intercommunication
• Queue that can hold 1 message = Mail box
Thread
Thread Thread
Thread Thread
Trang 30Summary of Thread Synchronization and Communication
Trang 31Summary of Thread Synchronization and Communication cont’d
Thread Synchronization
Event Notification
Mutual Exclusion
Inter-thread Communication