Powermax OS Programming Guide
Total Page:16
File Type:pdf, Size:1020Kb
PowerMAX OS Programming Guide 0890423-080 December 2001 Copyright 2001 by Concurrent Computer Corporation. All rights reserved. This publication or any part thereof is intended for use with Concurrent products by Concurrent personnel, customers, and end–users. It may not be reproduced in any form without the written permission of the publisher. The information contained in this document is believed to be correct at the time of publication. It is subject to change without notice. Concurrent makes no warranties, expressed or implied, concerning the information contained in this document. To report an error or comment on a specific portion of the manual, photocopy the page in question and mark the correction or comment on the copy. Mail the copy (and any additional comments) to Concurrent Computer Corpora- tion 2101 W. Cypress Creek Road, Ft. Lauderdale, FL 33309–1892. Mark the envelope “Attention: Publications Department.” This publication may not be reproduced for any other reason in any form without written permission of the publisher. This document is based on copyrighted documentation from Novell, Inc. and is reproduced with permission. UNIX is a registered trademark of The Open Group POSIX is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc. PowerPC and PowerPC 604 are trademarks of International Business Machines Corporation. PowerMAX OS and Power MAXION are trademarks of Concurrent Computer Corporation Printed in U. S. A. Revision History: Level: Effective With: Original Release -- August 1994 000 PowerUX 1.1 Previous Release -- August 1999 070 PowerMAX OS 4.3 Current Release -- December 2001 080 PowerMAX OS 5.1 Preface Scope of Manual This manual provides information needed for application programming in the PowerMAX OSTM1 operating system environment. It describes the system services provided by the system calls and libraries for the C programming language. It focuses on such topics as process scheduling, memory management, interprocess communications, and threads pro- gramming. Structure of Manual This manual consists of 14 chapters, 1 appendix, a glossary, and an index. A brief descrip- tion of the chapters and appendix is presented as follows: • Chapter 1 provides an introduction to the manual. • Chapter 2 introduces the system calls and other system services that you can use to develop application programs. • Chapter 3 discusses the system file and record locking facility. It also describes the STREAMS mechanism as it relates to input/output opera- tions. • Chapter 4 explains process management. • Chapter 5 provides an overview of process scheduling and describes: - System V scheduler classes - POSIX®2 scheduling policies - Scheduler priorities. • Chapter 6 provides an overview of primary memory and explains the pro- cedures for using memory management facilities. • Chapter 7 discusses the general terminal interface to control asynchronous communication ports. It also addresses the STREAMS mechanism as it relates to terminal device control. • Chapter 8 describes the programming interface to the internationalization feature. • Chapter 9 discusses file and directory management. Security consider- ations including privileges and device security are also described. 1. PowerMAX OS is a trademark of Concurrent Computer Corporation 2. POSIX is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc. iii PowerMAX OS Programming Guide • Chapter 9 provides a detailed explanation of three interprocess communi- cation facilities: - signals - job control - pipes. • Chapter 11 introduces the Threads Library, which provides facilities for concurrent programming. • Chapter 12 describes the InterProcess Communications (IPC) package that allows processes to exchange data and synchronize execution. The system calls for three IPC mechanisms are described: - messages - semaphores - shared memory. This chapter also describes the POSIX shared memory facilities. • Chapter 13 discusses the synchronous polling mechanism and asynchro- nous event notification within STREAMS. It also explains STREAMS input/output multiplexing. • Chapter 14 describes how to package software applications. • Appendix A provides guidelines for writing trusted software. The glossary contains definitions of technical terms that are important to understanding the concepts presented in this book. The index contains an alphabetical reference to key terms and concepts and numbers of pages where they occur in the text. Syntax Notation The following notation is used throughout this guide: italic Books, reference cards, and items that the user must specify appear in italic type. Special terms may also appear in italic. list bold User input appears in list bold type and must be entered exactly as shown. Names of directories, files, commands, options and man page references also appear in list bold type. list Operating system and program output such as prompts and mes- sages and listings of files and programs appears in list type. [] Brackets enclose command options and arguments that are optional. You do not type the brackets if you choose to specify such option or arguments iv Preface Referenced Publications The following publications are referenced in this document: 0890240 hf77 Fortran Reference Manual 0890424 Character User Interface Programming 0890429 System Administration Volume 1 0890430 System Administration Volume 2 0890431 Concurrent C Reference Manual 0890459 Compilation Systems Volume 1 (Tools) 0890460 Compilation Systems Volume 2 (Concepts) 0890466 PowerMAX OS Real-Time Guide v PowerMAX OS Programming Guide vi Contents Chapter 1 Introduction Introduction . 1-1 Audience and Prerequisite Knowledge. 1-1 Related Books and Documentation . 1-1 Programming Books . 1-1 Reference Set. 1-2 The C Connection. 1-3 Hardware/Software Dependencies . 1-3 Information in the Examples . 1-3 Notation Conventions . 1-3 Manual Page References . 1-4 Application Programming in the UNIX System Environment . 1-4 UNIX System Tools and Languages . 1-5 Facilities Covered and Not Covered in This Guide. 1-5 Programming Tools and Languages in the UNIX System Environment . 1-6 The C Language . 1-6 Shell. 1-7 awk . 1-7 lex . 1-7 yacc . 1-8 m4 . 1-8 bc and dc . 1-8 Character User Interfaces . 1-8 curses. 1-8 FMLI . 1-8 ETI. 1-9 Graphical User Interfaces. 1-10 XWIN Graphical Windowing System. 1-10 System Calls and Libraries . 1-11 File and Device Input/Output . 1-11 STREAMS Input/Output. 1-11 File and Record Locking. 1-14 Where to Find More Information . 1-15 Memory Management . 1-15 The Memory Mapping Interface . 1-15 Where to Find More Information . 1-16 Process Management and Scheduling . 1-16 Where to Find More Information . 1-16 Interprocess Communications . 1-16 Where to Find More Information . 1-18 Symbolic Links. 1-18 Where to Find More Information . 1-19 vii PowerMAX OS Programming Guide Chapter 2 System Calls and Libraries Introduction . 2-1 Libraries and Header Files . 2-1 Header Files . 2-1 How to Use Library Functions . 2-2 C Library (libc) . 2-6 Subsection 3C Routines. 2-6 Subsection 3S Routines . 2-9 Math Library (libm) . 2-10 General Purpose Library (libgen) . 2-12 Standard I/O Library. 2-14 Three Files You Always Have . 2-14 Named Files. 2-14 How C Programs Communicate with the Shell . 2-16 Passing Command Line Arguments . 2-16 System Calls. 2-18 Input/Output and File System Calls . 2-19 File and Device I/O . 2-19 Terminal Device Control . 2-19 Directory and File System Control . 2-20 Access Control System Calls. ..