You are on page 1of 13

om

.c
ng
Introduction to RTOS

co
an
th
o ng
du
u
cu

CuuDuongThanCong.com https://fb.com/tailieudientucntt
About SwiftACT

om
• A Technology services startup company

.c
o Under establishment

ng
co
• Areas of specialties:

an
o Mobile telecommunication services development
Embedded systems development

th
o
ng
• Types of services:
o
du

o Consultation
o Managed services
u

o Sourcing
cu

o Training

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
About Me

om
• Graduated 2004

.c
o ECE, ASU: 5 yrs distinction

ng
• 5+ years in embedded systems development

co
o SDLC, Apps, MW, DD, Porting, ...
• 3+ years in SW engineering

an
PSP, CMMI, Systematic reuse, ...

th
o
• 3+ years in SW testing ng
o IBM certified, ISTQB certified, ...
o
du
u
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Copyright

om
• Materials in this course is the property of Amr Ali Abdel-Naby.

.c
ng
• Reproduction or transmission of the materials in any manner

co
without the copyright owner permission is a law violation.

an
th
o ng
du
u
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Outline

om

.c
Introduction
• Tasks

ng
• Semaphores

co
• Message Queues

an
• Other Kernel Objects

th
• Other Kernel Services o ng
du
u
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Outline

om

.c
Introduction
• Tasks

ng
• Semaphores

co
• Message Queues

an
• Other Kernel Objects

th
• Other Kernel Services o ng
du
u
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
The RTOS Multitasking Model

om
• Multiple tasks

.c
o Each a sequential “thread” of execution

ng
co
• Explicit task manipulation Task 1 Task 2 Task 3

an
o Separate context for each task

th
ng
P1 P2 P3
o
• Pre-emption is dynamic: The highest priority ready task is the
du

Kernel
task that must be running
u
cu

Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Definition of a Task

om
• A task is an independent thread of execution capable of

.c
executing in parallel with other threads of execution.

ng
• Each task has its own stack.

co
o Maybe more than 1 stack
 Supervisor mode stack, user mode stack

an
• A task may synchronize and/or communicate with other tasks.

th
o Primary mechanism is messages.ng
o Also shared memory (with semaphores)
o
• You must write programs for your application tasks.
du

o Tasks may make service calls to the RTOS, to invoke RTOS


u

services.
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
The Task Control Block - TCB

om
Task 3
• Managed by RTOS for each task

.c
o Current state of task

ng
o Unique ID of task

co
o Priority of task TCB 3
Type of task

an
o
Task 2
o Stack location and size

th
o Current stack pointer ng
o File and line info (for debug)
o
o Waiting messages
du

TCB 2
o Desired messages
u

o ... Task 1
cu

• Useful for debugging, error handling

TCB 1

Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Task States & Transitions

om
.c
ng
Ready

co
an
HPT became ready
Needed resource is

th
available + HPT is
ready ng
No HPT is ready
o
du
u
cu

Blocked Needed resource is Running


available + No HPT is
ready

Needed resource is
unavailable
Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
CuuDuongThanCong.com https://fb.com/tailieudientucntt
System vs. Application Tasks

om
• Systems tasks

.c
o Created by the kernel

ng
o Have reserved priorities

co
o Initialization task, Idle task, logging task …

an
• The kernel jumps to a predefined entry point.

th
ng
• From the entry point, the developer can
o
du

o Initialize and create other application tasks ,


o As well as other kernel objects, which the application design might
u

require.
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Typical Task Operations

om
• Task creation and deletion

.c
o Create

ng
o Delete

co
• Task scheduling

an
o Suspend and Resume
o Get Priority and Set Priority

th
o Preemption Lock and Preemption unlock
ng
o Delay
o
o Restart
du

• Obtaining task information


u

o Get ID
cu

o Get TCB

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt
Typical Task Structure

om
.c
ng
co
Run to Completion Endless Loop

an
RunToCompletionTask(){ EndLessLoopTask(){

th
Initialize application Initialization code
Create kernel objects ng Loop forever {
Create endless loop tasks Loop body
o
Delete or Suspend task }
du

} }
u
cu

Amr Ali Abdel-Naby@2010 Introduction to RTOS


CuuDuongThanCong.com https://fb.com/tailieudientucntt

You might also like