Tải bản đầy đủ (.ppt) (31 trang)

RTOS building blocks for system development

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (288.79 KB, 31 trang )

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: 5 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 1 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


Data 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
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 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


Thread
• 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.

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:
o
o
o
o

Task’s priority
Task’s state
A pointer to the task’s top of stack
Other task’s related data

• TCBs 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 Pool
o

Fixed size based
 Size > 1 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


×