Lesson-9: Basic RTOS Functions in VxWorks

35
2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 REAL TIME OPERATING SYSTEM REAL TIME OPERATING SYSTEM PROGRAMMING PROGRAMMING - - I: I: µ µ C/OS C/OS - - II and II and VxWorks VxWorks Lesson Lesson - - 9: 9: Basic RTOS Functions in VxWorks

Transcript of Lesson-9: Basic RTOS Functions in VxWorks

Page 1: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

1

REAL TIME OPERATING SYSTEM REAL TIME OPERATING SYSTEM PROGRAMMINGPROGRAMMING--I: I: µµC/OSC/OS--II and II and

VxWorks VxWorks

LessonLesson--9: 9: Basic RTOS Functions in VxWorks

Page 2: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

2

RTOS Programming Tools: MicroC/OS-II and VxWorks

Lesson 9:Basic RTOS Functions in VxWorks

Page 3: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

3

1. 1. VxWorks Features

Page 4: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

4

WindRiverWindRiver VxWorksVxWorks•• HighHigh--performance, Unixperformance, Unix--like, like,

multitasking Environment scalable and scalable and hierarchical RTOShierarchical 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

Page 5: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

5

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,…

Page 6: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

6

VxWorks RTOS Kernel…VxWorks RTOS Kernel…•• Hard real time applicationsHard real time applications•• Supports kernel mode execution of Supports kernel mode execution of

taskstasks• Supports open source Linux and TIPC

(transparent inter process communication) protocol

Page 7: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

7

VxWorks RTOS Kernel…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

Page 8: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

8

VxWorks RTOS Kernel…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]

Page 9: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

9

VxWorks RTOS Kernel…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 7.14 and 7.15)� Virtual Memory Management

functions

Page 10: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

10

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

Page 11: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

11

HostHost--Target Development ApproachTarget 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

Page 12: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

12

ScalabilityScalability

� Scalable OS – only needed OS functions become part of the application codes

� Configuration file includes the user definitions for the needed IPC functions needed

Page 13: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

13

Hierarchical 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.

Page 14: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

14

• 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 Protected Environment

Page 15: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

15

• 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 FilesHeader Files

Page 16: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

16

VxWorks Basic Functions 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

Page 17: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

17

• IPCs – Semaphore, Queue and Pipes, POSIX IPCs

• No Mailbox • Queue permit array of messages• Network Functions• IO Functions

VxWorks Basic Functions… VxWorks Basic Functions…

Page 18: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

18

2. 2. Signal (Software interrupt from task) Handling

Page 19: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

19

Signal 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

Page 20: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

20

3. 3. Semaphore Functions

Page 21: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

21

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

Page 22: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

22

Two ways in which a pending task Two ways in which a pending task among the pending tasks unblockamong the pending tasks unblock

• Provides for– (a) as per task priority (b) as a FIFO, when accepting or taking an IPC

Page 23: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

23

4. 4. Queues Functions

Page 24: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

24

Queue…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

Page 25: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

25

QueueQueue• 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

Page 26: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

26

5. 5. Virtual device Functions

Page 27: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

27

5. 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

Page 28: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

28

6. 6. Task Service Functions

Page 29: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

29

Task functionsTask 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

Page 30: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

30

7. 7. VxWorks Functions naming Basics

Page 31: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

31

VxWorks Naming Basics 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|

Page 32: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

32

SummarySummary

Page 33: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

33

We learntWe 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

Page 34: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

34

We learntWe learnt• task, • memory• pipes, • files • network • IPC

Page 35: Lesson-9: Basic RTOS Functions in VxWorks

2008 Chapter-9 L9: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

35

End of Lesson 9 onBasic RTOS Functions in VxWorks