lesson-9: basic rtos functions in vxworks

36
2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 1 REAL TIME OPERATING SYSTEM PROGRAMMING-I: C/OS-II and VxWorks Lesson-9: Basic RTOS Functions in VxWorks

Upload: khangminh22

Post on 27-Jan-2023

1 views

Category:

Documents


0 download

TRANSCRIPT

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 1

REAL TIME OPERATING SYSTEM

PROGRAMMING-I: C/OS-II and

VxWorks

Lesson-9:

Basic RTOS Functions in VxWorks

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 2

1. VxWorks Features

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 3

WindRiver VxWorks

• High-performance, Unix-like,

multitasking Environment scalable and

hierarchical RTOS

• Host and target based development

approach

• Supports ‘Device Software Optimization

─ a new methodology that enables

development and running of device

software faster, better and more reliably

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 4

VxWorks RTOS Kernel…

• VxWorks 6.x processor abstraction

layer

• The layer enables application design

for new versions later by just changing

the layer-hardware interface

• Supports advanced processor

architectures─ ARM, ColdFire, MIPS,

Intel, SuperH,…

Presently Needed RTOS Features

Secure, intelligent, connected devices

is constantly expanding

Embedded devices becoming more

complex and use Complex Processors

Device Software Optimisation

Internet connectivity allows new levels

of remote management but also calls

for increased levels of security. 2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 5

Wind River VxWorks Platforms 6.9

Latest Version comprehensive multi-

core processor support, including

asymmetric

multiprocessing (AMP) and symmetric

multiprocessing (SMP) operating

system configurations as well as

hardware optimized multi-core

acceleration capabilities

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 6

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 7

VxWorks RTOS Kernel…

• Hard real time applications

• Supports kernel mode execution of tasks

• Supports open source Linux and TIPC

(transparent inter process

communication) protocol

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 8

VxWorks RTOS Kernel…

• Provides for the preemption points at

kernel

• Provides preemptive as well as round

robin scheduling,

• Support POSIX standard asynchronous

IOs

• Support UNIX standard buffered I/Os

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 9

VxWorks RTOS Kernel…

• PTTS 1.1 (Since Dec. 2007)

• IPCs in TIPC for network and clustered

system environment

• POSIX 1003.1b standard IPCs and

interfaces additional availability

• Separate context for tasks and ISRs

[Each task has a separate TCB, while

ISRs a common stack]

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 10

VxWorks RTOS Kernel… Schedules the ISRs separately and has

special functions for interrupt handling

Watchdog timers

Virtual I/O devices including the pipes

and sockets (Sections 9.14 and 9.15)

Virtual Memory Management

functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 11

VxWorks RTOS Kernel…

Power management functions that enhance the ability to control power consumption

Automatic detection and reporting of common memory and other errors

Interconnect functions that support large number of protocols

APIs for IPv4/IPv6 dual mode stack

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 12

Host-Target Development Approach

• Host Windows, Linux or Unix for Embedded Development and cross compiled for target system processor

RTOS ROM resident code downloaded to the using TCP/IP or serial port to a target board

Target has no virtual memory support and needed kernel functions are at the target ROM

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 13

Scalability

Scalable OS – only needed OS

functions become part of the

application codes

Configuration file includes the user

definitions for the needed IPC

functions needed

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 14

Hierarchical

RTOS kernel extendibility and

interfaces hierarchy includes timers,

signals, TCP/IP Sockets, queuing

functions library, NFS, RPCs,

Berkeley Port and Sockets, Pipes, Unix

compatible loader, language

interpreter, shell, debugging tools and

linking loader for Unix.

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 15

• Protection features – for example, if a

task is expecting a message from another

task, which is being deleted by using the

task-delete function, then RTOS inhibits

the deletion

• No priority inversion problem─ the task gets an inherited priority when option

of priority inheritance selected

Protected Environment

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 16

• VxWorks.h – header file

• kernelLib.h – kernel library functions

header file

• taskLib.h – tasks library functions

header file

• sysLib.h system library functions

header file

Header Files

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 17

VxWorks Basic Functions

• System Level – OS initiate, start, system timer clock rate set, ISR enter and exit, enable and disable

• Task Service Functions – initiate, resume, activate, run, suspend, (now or after delay)

• Task control functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 18

• IPCs – Semaphore, Queue and Pipes,

POSIX IPCs

• No Mailbox

• Queue permit array of messages

• Network Functions

• IO Functions

VxWorks Basic Functions…

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 19

2. Signal (Software interrupt from

task) Handling

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 20

Signal

• IPC signal used for exception handling or handling software interrupt event

• Signal-servicing routine─ a C function, which executes on occurrence of an interrupt or exception.

• Signal connect function connects the function with an interrupt vector

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 21

3. Semaphore Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 22

Semaphore functions for Synchronization

• event signal flag,

• mutually exclusive access using resource

key (mutex) and

• counting mechanism using three type of

semaphores in the tasks and ISRs

• P-V semaphore functions when POSIX

library included

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 23

Two ways in which a pending task

among the pending tasks unblock

• Provides for– (a) as per task priority

(b) as a FIFO, when accepting or

taking an IPC

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 24

4. Queues Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 25

Queue…

• Instead of queuing the message

pointers in C/OS-II , provides for

queuing of the messages.

• Queues can be used for priority posting

of message using post front as in

C/OS-II

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 26

Queue

• Provides for two ways in which a

pending task among the pending tasks

can unblock – (a) as per task priority

(b) as a FIFO, when accepting or

taking an IPC

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 27

5. Virtual device Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 28

5. Virtual device Functions

Pipe Drivers for inter-process

communications as an I/O virtual device

Network-transparent sockets.

Network drivers for shared memory and

Ethernet.

RAM "disk" drivers for memory resident

files

files

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 29

6. Task Service Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 30

Task functions

• Task creation and activation distinct states

• Functions for the task creating, running, waiting, suspending (inhibiting task-execution) and resuming, spawning (creating followed by activating), task-pending cum suspending and pending cum suspension with timeout functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 31

7. VxWorks Functions naming Basics

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 32

VxWorks Naming Basics

No OS or OS_ prefix for functions

For example, taskInit ( ) - a

VxWorks function, which initiates a

task

Prefix VX_ for the options and macros

For example, VX_PIVATE_ENV

VX_NO_STACK_FILL|

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 33

Summary

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 34

We learnt

• VxWorks basic features in the functions

• high performance,

• scalable and hierarchical

• OS initiate and start

• scheduling

• error handling

• system clock and service

• time delay

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 35

We learnt

• task,

• memory

• pipes,

• files

• network

• IPC

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design",

Raj Kamal, Publs.: McGraw-Hill Education 36

End of Lesson 9 on

Basic RTOS Functions in VxWorks