VxWorks
APPLICATION PROGRAMMER'S GUIDE
6.8
®
VxWorks Application Programmer's Guide, 6.8
Copyright © 2009 Wind River Systems, Inc.
All rights reserved. No part of this publication may be reproduced or transmitted in any
form or by any means without the prior written permission of Wind River Systems, Inc.
Wind River, Tornado, and VxWorks are registered trademarks of Wind River Systems, Inc.
The Wind River logo is a trademark of Wind River Systems, Inc. Any third-party
trademarks referenced are the property of their respective owners. For further information
regarding Wind River trademarks, please see:
www.windriver.com/company/terms/trademark.html
This product may include software licensed to Wind River by third parties. Relevant
notices (if any) are provided in your product installation at the following location:
installDir/product_name/3rd_party_licensor_notice.pdf.
Wind River may refer to third-party documentation by listing publications or providing
links to third-party Web sites for informational purposes. Wind River accepts no
responsibility for the information provided in such third-party documentation.
Corporate Headquarters
Wind River
500 Wind River Way
Alameda, CA 94501-1153
U.S.A.
Toll free (
U.S.A.): 800-545-WIND
Telephone: 510-748-4100
Facsimile: 510-749-2010
For additional contact information, see the Wind River Web site:
www.windriver.com
For information on how to contact Customer Support, see:
www.windriver.com/support
VxWorks
Application Programmer's Guide
6.8
28 Oct 09
iii
Contents
1 Overview ...................................................................................................... 1
1.1 Introduction ...................................................................................................................... 1
1.2 Related Documentation Resources .............................................................................. 1
1.3 VxWorks Configuration and Build .............................................................................. 2
2 Real-Time Processes .................................................................................. 3
2.1 Introduction ...................................................................................................................... 3
2.2 About Real-time Processes ............................................................................................ 4
2.2.1 RTPs and Scheduling ........................................................................................ 5
2.2.2 RTP Creation ...................................................................................................... 5
2.2.3 RTP Termination ............................................................................................... 6
2.2.4 RTPs and Memory ............................................................................................ 7
Virtual Memory Models ................................................................................... 7
Memory Protection ........................................................................................... 7
2.2.5 RTPs and Tasks .................................................................................................. 8
Numbers of Tasks and RTPs ........................................................................... 8
Initial Task in an RTP ....................................................................................... 8
RTP Tasks and Memory ................................................................................... 8
2.2.6 RTPs and Inter-Process Communication ....................................................... 9
2.2.7 RTPs, Inheritance, Zombies, and Resource Reclamation ............................ 9
Inheritance .......................................................................................................... 9
Zombie Processes .............................................................................................. 9
Resource Reclamation ...................................................................................... 10
2.2.8 RTPs and Environment Variables ................................................................... 10
Setting Environment Variables From Outside a Process ............................ 10
Setting Environment Variables From Within a Process .............................. 11
2.2.9 RTPs and POSIX ................................................................................................ 11
POSIX PSE52 Support ....................................................................................... 11
VxWorks
Application Programmer's Guide, 6.8
iv
2.3 Configuring VxWorks For Real-time Processes ....................................................... 12
2.3.1 Basic RTP Support ............................................................................................. 12
2.3.2 MMU Support for RTPs ................................................................................... 13
2.3.3 Additional Component Options ..................................................................... 13
2.3.4 Configuration and Build Facilities .................................................................. 15
2.4 Using RTPs Without MMU Support ........................................................................... 15
Configuation With Process Support and Without an MMU ...................... 16
2.5 About VxWorks RTP Virtual Memory Models ........................................................ 16
2.5.1 Flat RTP Virtual Memory Model ................................................................... 16
2.5.2 Overlapped RTP Virtual Memory Model ..................................................... 17
2.6 Using the Overlapped RTP Virtual Memory Model ............................................... 19
2.6.1 About User Regions and the RTP Code Region .......................................... 19
User Regions of Virtual Memory .................................................................... 19
RTP Code Region in Virtual Memory ........................................................... 20
2.6.2 Configuring VxWorks for Overlapped RTP Virtual Memory ................... 21
Getting Information About User Regions ..................................................... 22
Identifying the RTP Code Region ................................................................... 23
Setting Configuration Parameters for the RTP Code Region ..................... 24
2.6.3 Using RTP Applications With Overlapped RTP Virtual Memory ............ 26
Building Absolutely-Linked RTP Executables .............................................. 26
Stripping Absolutely-Linked RTP Executables ........................................... 27
Executing Absolutely-Linked RTP Executables .......................................... 28
Executing Relocatable RTP Executables ........................................................ 28
3 RTP Applications ........................................................................................ 29
3.1 Introduction ...................................................................................................................... 29
3.2 Configuring VxWorks For RTP Applications .......................................................... 30
3.3 Developing RTP Applications ...................................................................................... 30
RTP Applications With Shared Libraries and Plug-Ins ............................... 31
RTP Applications for the Overlapped Virtual Memory Model ................. 31
RTP Applications for UP and SMP Configurations of VxWorks ............... 31
Migrating Kernel Applications to RTP Applications ................................... 31
3.3.1 RTP Application Structure ............................................................................... 31
3.3.2 VxWorks Header Files ...................................................................................... 32
POSIX Header Files ........................................................................................... 32
VxWorks Header File: vxWorks.h .................................................................. 33
Other VxWorks Header Files .......................................................................... 33
ANSI Header Files ............................................................................................ 33
ANSI C++ Header Files .................................................................................... 33
Compiler -I Flag ................................................................................................. 33
Contents
v
VxWorks Nested Header Files ........................................................................ 34
VxWorks Private Header Files ........................................................................ 34
3.3.3 RTP Application APIs: System Calls and Library Routines ....................... 35
VxWorks System Calls ..................................................................................... 35
VxWorks Libraries ............................................................................................ 35
Dinkum C and C++ Libraries .......................................................................... 36
Custom Libraries ............................................................................................... 36
API Documentation .......................................................................................... 36
3.3.4 Reducing Executable File Size With the strip Facility ................................. 36
3.3.5 RTP Applications and Multitasking ............................................................... 36
3.3.6 Checking for Required Kernel Support ......................................................... 37
3.3.7 Using Hook Routines ........................................................................................ 37
3.3.8 Developing C++ Applications ......................................................................... 37
3.3.9 Using POSIX Facilities ...................................................................................... 37
3.3.10 Building RTP Applications .............................................................................. 37
3.4 Developing Static Libraries, Shared Libraries and Plug-Ins .................................. 38
3.5 Creating and Using Shared Data Regions .................................................................. 38
3.5.1 Configuring VxWorks for Shared Data Regions .......................................... 39
3.5.2 Creating Shared Data Regions ........................................................................ 39
3.5.3 Accessing Shared Data Regions ...................................................................... 40
3.5.4 Deleting Shared Data Regions ......................................................................... 40
3.6 Executing RTP Applications ......................................................................................... 40
Caveat With Regard to Stripped Executables ............................................... 41
Starting an RTP Application ............................................................................ 41
Stopping an RTP Application .......................................................................... 41
Storing Application Executables ..................................................................... 42
3.6.1 Running Applications Interactively ............................................................... 42
Starting Applications ........................................................................................ 43
Terminating Applications ................................................................................ 43
3.6.2 Running Applications Automatically ............................................................ 44
Startup Facility Options ................................................................................... 44
Application Startup String Syntax .................................................................. 45
Specifying Applications with a Startup Configuration Parameter ............ 46
Specifying Applications with a Boot Loader Parameter ............................. 46
Specifying Applications with a VxWorks Shell Script ................................. 47
Specifying Applications with usrRtpAppInit( ) .......................................... 48
3.6.3 Spawning Tasks and Executing Routines in an RTP Application ............. 49
3.6.4 Applications and Symbol Registration .......................................................... 49
3.7 Bundling RTP Applications in a System using ROMFS ......................................... 50
3.7.1 Configuring VxWorks with ROMFS .............................................................. 50