Introduction to RTOS
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
Introduction to RTOS
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
Introduction to RTOS
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
Introduction to RTOS
Outline
•
•
•
•
•
•
Introduction
Tasks
Semaphores
Message Queues
Other Kernel Objects
Other Kernel Services
Amr Ali Abdel-Naby@2010
Introduction to RTOS
Outline
•
•
•
•
•
•
Introduction
Tasks
Semaphores
Message Queues
Other Kernel Objects
Other Kernel Services
Amr Ali Abdel-Naby@2010
Introduction to RTOS
The RTOS Multitasking Model
• Multiple tasks
o
Each a sequential “thread” of execution
• Explicit task manipulation
o
Task 1
Task 2
Task 3
Separate context for each task
P1
P2
P3
• Pre-emption is dynamic: The highest priority ready task is the
Kernel
task that must be running
Amr Ali Abdel-Naby@ 2009
Real-Time Operating Systems
Definition of a Task
• A task is an independent thread of execution capable of
executing in parallel with other threads of execution.
• Each task has its own stack.
o
Maybe more than 1 stack
Supervisor mode stack, user mode stack
• A task may synchronize and/or communicate with other tasks.
o
o
Primary mechanism is messages.
Also shared memory (with semaphores)
• You must write programs for your application tasks.
o
Tasks may make service calls to the RTOS, to invoke RTOS
services.
Amr Ali Abdel-Naby@2010
Introduction to RTOS
The Task Control Block - TCB
• Managed by RTOS for each task
o
o
o
o
o
o
o
o
o
o
Current state of task
Unique ID of task
Priority of task
Type of task
Stack location and size
Current stack pointer
File and line info (for debug)
Waiting messages
Desired messages
...
Task 3
TCB 3
Task 2
TCB 2
Task 1
• Useful for debugging, error handling
TCB 1
Amr Ali Abdel-Naby@ 2009
Real-Time Operating Systems
Task States & Transitions
Ready
Needed resource is
available + HPT is
ready
Blocked
Amr Ali Abdel-Naby@ 2009
HPT became ready
No HPT is ready
Needed resource is
available + No HPT is
ready
Running
Needed resource is
unavailable
Real-Time Operating Systems
System vs. Application Tasks
• Systems tasks
o
o
o
Created by the kernel
Have reserved priorities
Initialization task, Idle task, logging task …
• The kernel jumps to a predefined entry point.
• From the entry point, the developer can
o
o
Initialize and create other application tasks ,
As well as other kernel objects, which the application design might
require.
Amr Ali Abdel-Naby@2010
Introduction to RTOS
Typical Task Operations
• Task creation and deletion
o
o
Create
Delete
• Task scheduling
o
o
o
o
o
Suspend and Resume
Get Priority and Set Priority
Preemption Lock and Preemption unlock
Delay
Restart
• Obtaining task information
o
o
Get ID
Get TCB
Amr Ali Abdel-Naby@2010
Introduction to RTOS
Typical Task Structure
Run to Completion
RunToCompletionTask(){
Initialize application
Create kernel objects
Create endless loop tasks
Delete or Suspend task
}
Amr Ali Abdel-Naby@2010
Endless Loop
EndLessLoopTask(){
Initialization code
Loop forever {
Loop body
}
}
Introduction to RTOS