Vxworks ® Programmer’S Guide
Total Page:16
File Type:pdf, Size:1020Kb
VxWorks ® Programmer’s Guide 5.4 Edition 1 An ISO 9001 Registered Company Copyright 1984 – 1999 Wind River Systems, Inc. ALL RIGHTS RESERVED. No part of this publication may be copied in any form, by photocopy, microfilm, retrieval system, or by any other means now known or hereafter invented without the prior written permission of Wind River Systems, Inc. VxWorks, IxWorks, Wind River Systems, the Wind River Systems logo, wind, and Embedded Internet are registered trademarks of Wind River Systems, Inc. CrossWind, Tornado, VxMP, VxSim, VxVMI, WindC++, WindConfig, Wind Foundation Classes, WindNet, WindPower, WindSh, and WindView are trademarks of Wind River Systems, Inc. All other trademarks used in this document are the property of their respective owners. Corporate Headquarters Europe Japan Wind River Systems, Inc. Wind River Systems, S.A.R.L. Wind River Systems Japan 1010 Atlantic Avenue 19, Avenue de Norvège Pola Ebisu Bldg. 11F Alameda, CA 94501-1153 Immeuble B4, Bâtiment 3 3-9-19 Higashi USA Z.A. de Courtaboeuf 1 Shibuya-ku 91953 Les Ulis Cédex Tokyo 150 FRANCE JAPAN toll free (US): 800/545-WIND telephone: 510/748-4100 telephone: 33-1-60-92-63-00 telephone: 81-3-5467-5900 facsimile: 510/749-2010 facsimile: 33-1-60-92-63-15 facsimile: 81-3-5467-5877 CUSTOMER SUPPORT Telephone E-mail Fax Corporate: 800/872-4977 toll free, U.S. & Canada [email protected] 510/749-2164 510/748-4100 direct Europe: 33-1-69-07-78-78 [email protected] 33-1-69-07-08-26 Japan: 011-81-3-5467-5900 [email protected] 011-81-3-5467-5877 If you purchased your Wind River Systems product from a distributor, please contact your distributor to determine how to reach your technical support organization. Please provide your license number when contacting Customer Support. VxWorks Programmer’s Guide, 5.4 Edition 1 6 May 99 Part #: DOC-12629-ZD-01 1 Overview ............................................................................... 1 2 Basic OS ............................................................................... 19 3 I/O System ............................................................................ 95 4 Local File Systems .............................................................. 175 5 C++ Development ................................................................ 227 6 Shared-Memory Objects ..................................................... 255 7 Virtual Memory Interface .................................................... 289 8 Configuration and Build ...................................................... 309 9 Target Shell .......................................................................... 369 Appendices .......................................................................... 381 A Motorola MC680x0 ............................................................... 383 B Sun SPARC, SPARClite ....................................................... 399 C Intel i960 ............................................................................... 417 D Intel x86 ................................................................................ 429 E MIPS R3000, R4000, R4650 ................................................. 477 F PowerPC ............................................................................... 489 G ARM ...................................................................................... 503 H VxSim .................................................................................... 525 I Coding Conventions ............................................................ 555 Index ..................................................................................... 577 iii Contents 1 Overview ........................................................................................................................... 1 1.1 Introduction ...................................................................................................... 1 1.2 Getting Started with the Tornado Development System ............................ 2 1.3 VxWorks: A Partner in the Real-time Development Cycle ........................ 2 1.4 VxWorks Facilities: An Overview .................................................................. 3 Multitasking and Intertask Communications ................................ 6 POSIX Interfaces ................................................................................. 6 I/O System .......................................................................................... 7 Local File Systems .............................................................................. 8 Virtual Memory (Including VxVMI Option) .................................. 10 Shared-Memory Objects (VxMP Option) ....................................... 10 Target-Resident Tools ........................................................................ 11 C++ Development (including Wind Foundation Classes Option) 11 Utility Libraries .................................................................................. 11 Performance Evaluation .................................................................... 13 Target Agent ....................................................................................... 14 Board Support Packages (BSPs) ....................................................... 15 VxWorks Simulator (VxSim Option) ............................................... 15 1.5 Customer Services ............................................................................................ 16 1.6 Documentation Conventions .......................................................................... 17 v VxWorks 5.4 Programmer’s Guide 2 Basic OS ........................................................................................................................... 19 2.1 Introduction ...................................................................................................... 19 2.2 Wind Features and POSIX Features .............................................................. 20 2.3 Tasks ................................................................................................................... 20 2.3.1 Multitasking ....................................................................................... 20 2.3.2 Task State Transition .......................................................................... 21 2.3.3 Wind Task Scheduling ...................................................................... 22 Preemptive Priority Scheduling ...................................................... 23 Round-Robin Scheduling ................................................................. 23 Preemption Locks .............................................................................. 25 2.3.4 Tasking Control .................................................................................. 25 Task Creation and Activation .......................................................... 25 Task Names and IDs .......................................................................... 26 Task Options ....................................................................................... 27 Task Information ................................................................................ 28 Task Deletion and Deletion Safety .................................................. 28 Task Control ........................................................................................ 30 2.3.5 Tasking Extensions ............................................................................ 31 2.3.6 POSIX Scheduling Interface ............................................................. 32 Differences Between POSIX and Wind Scheduling ...................... 32 Getting and Setting POSIX Task Priorities ..................................... 33 Getting and Displaying the Current Scheduling Policy .............. 35 Getting Scheduling Parameters: Priority Limits and Time Slice 35 2.3.7 Task Error Status: errno .................................................................... 36 Layered Definitions of errno ............................................................ 36 A Separate errno Value for Each Task ............................................ 37 Error Return Convention .................................................................. 37 Assignment of Error Status Values ................................................. 38 2.3.8 Task Exception Handling ................................................................. 38 2.3.9 Shared Code and Reentrancy ........................................................... 39 Dynamic Stack Variables .................................................................. 40 Guarded Global and Static Variables .............................................. 40 vi Contents Task Variables ..................................................................................... 41 Multiple Tasks with the Same Main Routine ................................. 42 2.3.10 VxWorks System Tasks ...................................................................... 43 2.4 Intertask Communications .............................................................................. 45 2.4.1 Shared Data Structures ...................................................................... 45 2.4.2 Mutual Exclusion ............................................................................... 46 Interrupt Locks and Latency ............................................................ 46 Preemptive Locks and Latency ........................................................ 47 2.4.3 Semaphores ........................................................................................