REAL TIME PROGRAMMING-I: C/OS-II and VxWorks

Lesson-9: Basic RTOS Functions in VxWorks

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 1 Raj Kamal, Publs.: McGraw-Hill Education 1. VxWorks Features

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 2 Raj Kamal, Publs.: McGraw-Hill Education WindRiver VxWorks • High-performance, -like, multitasking Environment scalable and hierarchical RTOS • Host and target based development approach • Supports ‘Device 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", 3 Raj Kamal, Publs.: McGraw-Hill Education 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, , SuperH,…

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 4 Raj Kamal, Publs.: McGraw-Hill Education 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", 5 Raj Kamal, Publs.: McGraw-Hill Education 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", 6 Raj Kamal, Publs.: McGraw-Hill Education

VxWorks RTOS Kernel… • Hard real time applications • Supports kernel mode execution of tasks • Supports open source and TIPC (transparent inter communication) protocol

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 7 Raj Kamal, Publs.: McGraw-Hill Education VxWorks RTOS Kernel… • Provides for the points at kernel • Provides preemptive as well as round robin , • Support POSIX standard asynchronous IOs • Support UNIX standard buffered I/Os

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 8 Raj Kamal, Publs.: McGraw-Hill Education 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", 9 Raj Kamal, Publs.: McGraw-Hill Education VxWorks RTOS Kernel…  Schedules the ISRs separately and has special functions for 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", 10 Raj Kamal, Publs.: McGraw-Hill Education 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  for IPv4/IPv6 dual mode stack

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 11 Raj Kamal, Publs.: McGraw-Hill Education 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", 12 Raj Kamal, Publs.: McGraw-Hill Education 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", 13 Raj Kamal, Publs.: McGraw-Hill Education Hierarchical

 RTOS kernel extendibility and interfaces hierarchy includes timers, signals, TCP/IP Sockets, queuing functions , 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", 14 Raj Kamal, Publs.: McGraw-Hill Education Protected Environment • 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

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 15 Raj Kamal, Publs.: McGraw-Hill Education Header Files • 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

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 16 Raj Kamal, Publs.: McGraw-Hill Education VxWorks Basic Functions

• System Level – OS initiate, start, system timer clock rate set, ISR enter and , 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", 17 Raj Kamal, Publs.: McGraw-Hill Education VxWorks Basic Functions… • IPCs – , Queue and Pipes, POSIX IPCs • No Mailbox • Queue permit array of messages • Network Functions • IO Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 18 Raj Kamal, Publs.: McGraw-Hill Education 2. Signal (Software interrupt from task) Handling

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 19 Raj Kamal, Publs.: McGraw-Hill Education Signal

• IPC used for or handling software interrupt • 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", 20 Raj Kamal, Publs.: McGraw-Hill Education 3. Semaphore Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 21 Raj Kamal, Publs.: McGraw-Hill Education 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", 22 Raj Kamal, Publs.: McGraw-Hill Education 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", 23 Raj Kamal, Publs.: McGraw-Hill Education 4. Queues Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 24 Raj Kamal, Publs.: McGraw-Hill Education 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", 25 Raj Kamal, Publs.: McGraw-Hill Education 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", 26 Raj Kamal, Publs.: McGraw-Hill Education 5. Virtual device Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 27 Raj Kamal, Publs.: McGraw-Hill Education 5. Virtual device Functions

 Pipe Drivers for inter-process communications as an I/O virtual device

 Network-transparent sockets.

 Network drivers for and Ethernet.

 RAM "disk" drivers for memory resident files

 files

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 28 Raj Kamal, Publs.: McGraw-Hill Education 6. Task Service Functions

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 29 Raj Kamal, Publs.: McGraw-Hill Education 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", 30 Raj Kamal, Publs.: McGraw-Hill Education 7. VxWorks Functions naming Basics

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 31 Raj Kamal, Publs.: McGraw-Hill Education 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", 32 Raj Kamal, Publs.: McGraw-Hill Education Summary

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 33 Raj Kamal, Publs.: McGraw-Hill Education 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", 34 Raj Kamal, Publs.: McGraw-Hill Education We learnt • task, • memory • pipes, • files • network • IPC

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 35 Raj Kamal, Publs.: McGraw-Hill Education End of Lesson 9 on Basic RTOS Functions in VxWorks

2015 Chapter-11 L09: "Embedded Systems - Architecture, Programming and Design", 36 Raj Kamal, Publs.: McGraw-Hill Education