Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 31 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
31
Dung lượng
521,5 KB
Nội dung
RTOS Building Blocks for System Development About SwiftACT • A Technology services startup company o Under establishment • Areas of specialties: o o Mobile telecommunication services development Embedded systems development • Types of services: o o o o Consultation Managed services Sourcing Training Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development About Me • Graduated 2004 o ECE, ASU: yrs distinction • 5+ years in embedded systems development o SDLC, Apps, MW, DD, Porting, • 3+ years in SW engineering o PSP, CMMI, Systematic reuse, • 3+ years in SW testing o IBM certified, ISTQB certified, Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Copyright • 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 Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Introduction • RTOS = Objects + Services • Objects o o They are used to build the application Thread, Mutex… • Services o o They allow the developer to create, manipulate, and manage system resources and entities in order to facilitate application development Thread management APIs, Mutex management APIs… Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Defining Public Resources • Some objects are public o They can be accessed from any thread • Accessing a public object is not like owning it o o Mutex can be accessed from any thread A public object A mutex has only owner at a time A private ownership Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Memory Pools • Memory Block Pool o Fixed size based Size > byte o o o o o Each pool can have different block size Less flexible No fragmentation Faster access Used in most of RTOSes Amr Ali Abdel-Naby@2010 • Memory Byte Pool o o o o o Smallest size is byte Several C heaps Allocation is for any size Defragmentation is needed Faster allocation speed RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Application Timer • Enable applications to execute their functions at specific intervals of time • One-shot o Expire only once • Periodic o Repeating intervals Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Mutex • Controls threads access to a critical section • Priority inheritance • Priority ceiling Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Counting Semaphore • Used for o o o Event notification Thread synchronization Mutual exclusion but no ownership as in mutex Counting semaphore binary semaphore Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Event Flag Group • Event flag bit • Used for threads synchronization • Event flag group group of flags • Threads can operate on any or all of the event flags Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Message Queue • Used for thread intercommunication • Queue that can hold message = Mail box Thread Thread Thread Message Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Thread Thread Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Summary of Thread Synchronization and Communication Mutex • Slow • Only owner • Priority protocol • Mutual exclusion is primary usage • Can’t be used for synchronization • Can’t be used for notifications Amr Ali Abdel-Naby@2010 Counting Semaphore • Fast • No ownership • No priority protocol • Can be done with a binary semaphore • Can be used for synchronization • Can be used for notifications RTOS Building Blocks for System Development Thread Synchronization Event Notification Mutual Exclusion Counting Semaphore Better for event Preferred OK Event Flags Group Preferred OK Message Queues OK OK Inter-thread Communication Summary of Thread Synchronization Mutex Preferred and Communication cont’d Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Preferred [...]... Can be used for notifications RTOS Building Blocks for System Development Thread Synchronization Event Notification Mutual Exclusion Counting Semaphore Better for 1 event Preferred OK Event Flags Group Preferred OK Message Queues OK OK Inter-thread Communication Summary of Thread Synchronization Mutex Preferred and Communication cont’d Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development. .. of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Counting Semaphore • Used for o o o Event notification Thread synchronization Mutual exclusion but no ownership as in mutex Counting semaphore binary semaphore Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public... of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Event 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 Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public... Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Message Queue • Used for thread intercommunication • Queue that can hold 1 message = Mail box Thread Thread Thread Message Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Thread Thread Outline • • • • • • • • • • • Introduction Defining Public Resources... • Every process has at least 1 thread o Most RTOSes consist of a single process and multiple threads Process 1 Amr Ali Abdel-Naby@2010 Process 2 RTOS Building Blocks for System Development Process 3 Thread cont’d • Each thread has a Task Control Block (TCB) • Every task is assigned a TCB when created Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Thread cont’d • A TCB contains:... Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Application Timer • Enable applications to execute their functions at specific intervals of time • One-shot o Expire only once • Periodic o Repeating intervals Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public... Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Mutex • Controls threads access to a critical section • Priority inheritance • Priority ceiling Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory... reside in RAM Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Outline • • • • • • • • • • • Introduction Defining Public Resources Data Types Thread Memory Pools Application Timer Mutex Counting Semaphore Event Flag Group Message Queue Summary of Thread Synchronization and Communication Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Memory Pools • Memory Block... portable • RTOSes provide special data types o o o The wrap the C compiler primitive ones They ensure compiler and architecture portability In uCOS-II: INT8U, INT8, INT16U… Amr Ali Abdel-Naby@2010 RTOS Building Blocks for System Development Data Types cont’d • RTOS defines its own data types o o To define its own objects In uCOS-II: OS_EVENT, OS_STK, OS_FLAG_GROUP… Amr Ali Abdel-Naby@2010 RTOS Building Blocks. .. Abdel-Naby@2010 RTOS Building Blocks for System Development Summary of Thread Synchronization and Communication Mutex • Slow • Only 1 owner • Priority protocol • Mutual exclusion is primary usage • Can’t be used for synchronization • Can’t be used for notifications Amr Ali Abdel-Naby@2010 Counting Semaphore • Fast • No ownership • No priority protocol • Can be done with a binary semaphore • Can be used for synchronization