| Title and Copyright Information |
| About This Guide |
| Audience |
| Organization |
| Related Documents |
| Reader's Comments |
| Conventions |
| 1 | Introduction to Realtime Programming |
| 1.1 | Realtime Overview |
| 1.2 | Tru64 UNIX Realtime System Capabilities |
| 1.2.1 | The Value of a Preemptive Kernel |
| 1.2.1.1 | Nonpreemptive Kernel |
| 1.2.1.2 | Preemptive Kernel |
| 1.2.1.3 | Comparing Latency |
| 1.2.2 | Fixed-Priority Scheduling Policies |
| 1.2.3 | Realtime Clocks and Timers |
| 1.2.4 | Memory Locking |
| 1.2.5 | Asynchronous I/O |
| 1.2.6 | Synchronized I/O |
| 1.2.7 | Realtime Interprocess Communication |
| 1.3 | Process Synchronization |
| 1.3.1 | Waiting for a Specified Period of Time or an Absolute Time |
| 1.3.2 | Waiting for Semaphores |
| 1.3.3 | Waiting for Communication |
| 1.3.4 | Waiting for Another Process |
| 1.3.5 | Realtime Needs and System Solutions |
| 1.4 | POSIX Standards |
| 1.5 | Enabling Tru64 UNIX Realtime Features |
| 1.6 | Building Realtime Applications |
| 1.6.1 | Defining the POSIX Environment |
| 1.6.2 | Compiling and Linking Realtime Applications |
| 1.6.2.1 | Compiling Realtime Applications |
| 1.6.2.2 | Compiling Realtime Applications That Use Asynchronous I/O |
| 1.6.2.3 | Linking a Previously Compiled Realtime Application |
| 2 | The Tru64 UNIX Scheduler |
| 2.1 | Scheduler Fundamentals |
| 2.1.1 | Schedulable Entities |
| 2.1.2 | Thread States |
| 2.1.3 | Scheduler Database |
| 2.1.4 | Quantum |
| 2.1.5 | Scheduler Transitions |
| 2.2 | Scheduling Policies |
| 2.2.1 | The Nature of the Work |
| 2.2.2 | Timesharing Scheduling |
| 2.2.3 | Fixed-Priority Scheduling |
| 2.2.3.1 | First-In/First-Out Scheduling |
| 2.2.3.2 | Round-Robin Scheduling |
| 2.3 | Process Priorities |
| 2.3.1 | Priorities for the nice Interface |
| 2.3.2 | Priorities for the Realtime Interface |
| 2.3.3 | Displaying Realtime Priorities |
| 2.3.4 | Configuring Realtime Priorities |
| 2.4 | Scheduling Functions |
| 2.4.1 | Determining Limits |
| 2.4.2 | Retrieving the Priority and Scheduling Policy |
| 2.4.3 | Setting the Priority and Scheduling Policy |
| 2.4.4 | Yielding to Another Process |
| 2.5 | Priority and Policy Example |
| 3 | Shared Memory |
| 3.1 | Memory Objects |
| 3.1.1 | Opening a Shared-Memory Object |
| 3.1.2 | Opening Memory-Mapped Files |
| 3.1.3 | Mapping Memory-Mapped Files |
| 3.1.4 | Using File Functions |
| 3.1.5 | Controlling Memory-Mapped Files |
| 3.1.6 | Removing Shared Memory |
| 3.2 | Locking Shared Memory |
| 3.3 | Using Shared Memory with Semaphores |
| 4 | Memory Locking |
| 4.1 | Memory Management |
| 4.2 | Memory-Locking and Unlocking Functions |
| 4.2.1 | Locking and Unlocking a Specified Region |
| 4.2.2 | Locking and Unlocking an Entire Process Space |
| 5 | Signals |
| 5.1 | Overview of Signals |
| 5.2 | POSIX Signal Functions |
| 5.3 | Signal-Handling Basics |
| 5.3.1 | Specifying a Signal Action |
| 5.3.2 | Setting Signal Masks and Blocking Signals |
| 5.3.3 | Suspending a Process and Waiting for a Signal |
| 5.3.4 | Setting Up an Alternate Signal Stack |
| 5.4 | Realtime Signal Handling |
| 5.4.1 | Additional Realtime Signals |
| 5.4.2 | Queuing Signals to a Process |
| 5.4.2.1 | The siginfo_t Structure |
| 5.4.2.2 | The ucontext_t and sigcontext Structures |
| 5.4.2.3 | Sending a Realtime Signal with the sigqueue Function |
| 5.4.3 | Asynchronous Delivery of Other Realtime Signals |
| 5.4.4 | Responding to Realtime Signals Using the sigwaitinfo and sigtimedwait Functions |
| 6 | Clocks and Timers |
| 6.1 | Clock Functions |
| 6.1.1 | Retrieving System Time |
| 6.1.2 | Setting the Clock |
| 6.1.3 | Converting Time Values |
| 6.1.4 | System Clock Resolution |
| 6.1.5 | High-Resolution Clock |
| 6.2 | Types of Timers |
| 6.3 | Timers and Signals |
| 6.4 | Data Structures Associated with Timing Facilities |
| 6.4.1 | Using the timespec Data Structure |
| 6.4.2 | Using the itimerspec Data Structure |
| 6.4.3 | Using the sigevent Data Structure |
| 6.5 | Timer Functions |
| 6.5.1 | Creating Timers |
| 6.5.2 | Setting Timer Values |
| 6.5.3 | Retrieving Timer Values |
| 6.5.4 | Getting the Overrun Count |
| 6.5.5 | Disabling Timers |
| 6.6 | High-Resolution Sleep |
| 6.7 | Clocks and Timers Example |
| 7 | Asynchronous Input and Output |
| 7.1 | Data Structures Associated with Asynchronous I/O |
| 7.1.1 | Identifying the Location |
| 7.1.2 | Specifying a Signal |
| 7.2 | Asynchronous I/O Functions |
| 7.2.1 | Reading and Writing |
| 7.2.2 | Using List-Directed Input/Output |
| 7.2.3 | Determining Status |
| 7.2.4 | Canceling I/O |
| 7.2.5 | Blocking to Completion |
| 7.2.6 | Asynchronous File Synchronization |
| 7.3 | Asynchronous I/O to Raw Devices |
| 7.4 | Asynchronous I/O Examples |
| 7.4.1 | Using the aio Functions |
| 7.4.2 | Using the lio_listio Function |
| 8 | File Synchronization |
| 8.1 | How to Ensure Data or File Integrity |
| 8.1.1 | Using Function Calls |
| 8.1.2 | Using File Descriptors |
| 9 | Semaphores |
| 9.1 | Overview of Semaphores |
| 9.2 | The Semaphore Interface |
| 9.2.1 | Creating and Opening a Semaphore |
| 9.2.2 | Locking and Unlocking Semaphores |
| 9.2.3 | Priority Inversion with Semaphores |
| 9.2.4 | Closing a Semaphore |
| 9.3 | Semaphore Example |
| 10 | Messages |
| 10.1 | Message Queues |
| 10.2 | The Message Interface |
| 10.2.1 | Opening a Message Queue |
| 10.2.2 | Sending and Receiving Messages |
| 10.2.3 | Asynchronous Notification of Messages |
| 10.2.4 | Prioritizing Messages |
| 10.2.5 | Using Message Queue Attributes |
| 10.2.6 | Closing and Removing a Message Queue |
| 10.3 | Message Queue Examples |
| 11 | Realtime Performance and System Tuning |
| 11.1 | Realtime Responsiveness |
| 11.1.1 | Interrupt Service Routine Latency |
| 11.1.2 | Process Dispatch Latency |
| 11.2 | Improving Realtime Responsiveness |
| A | Tru64 UNIX Realtime Functional Summary |
| Examples |
| 2-1 | Initializing Priority and Scheduling Policy Fields |
| 2-2 | Using Priority and Scheduling Functions |
| 3-1 | Including a Shared-Memory Object |
| 3-2 | Locking a Memory Object |
| 4-1 | Aligning and Locking a Memory Segment |
| 4-2 | Using the mlockall Function |
| 5-1 | Sending a Signal to Another Process |
| 5-2 | Sending a Realtime Signal to Another Process |
| 5-3 | Using the sigwaitinfo Function |
| 5-4 | Using the sigwaitinfo Function |
| 6-1 | Returning Time |
| 6-2 | Using Timers |
| 7-1 | Using Asynchronous I/O |
| 7-2 | Using lio_listio in Asynchronous I/O |
| 9-1 | Locking a Semaphore |
| 9-2 | Using Semaphores and Shared Memory |
| 10-1 | Opening a Message Queue |
| 10-2 | Using Message Queues to Send Data |
| 10-3 | Using Message Queues to Receive Data |
| Figures |
| 1-1 | Nonpreemptive Kernel |
| 1-2 | Preemptive Kernel |
| 2-1 | Order of Execution |
| 2-2 | Process Events |
| 2-3 | Preemption Finishing a Quantum |
| 2-4 | Priority Ranges for the nice and Realtime Interfaces |
| 4-1 | Memory Allocation with mlock |
| 4-2 | Memory Allocation with mlockall |
| 5-1 | Signal Mask That Blocks Two Signals |
| Tables |
| 1-1 | Realtime Needs and System Solutions |
| 2-1 | Priority Ranges for the nice Interface |
| 2-2 | Priority Ranges for the Tru64 UNIX Realtime Interface |
| 3-1 | Memory-Mapping Functions |
| 3-2 | Status Flags and Access Modes for the shm_open Function |
| 3-3 | File Functions Used with Memory-Mapped Files |
| 5-1 | POSIX 1003.1 Signal Functions |
| 5-2 | POSIX 1003.1b Signal Functions |
| 5-3 | POSIX Signals |
| 6-1 | Values Used in Setting Timers |
| 10-1 | Status Flags and Access Modes for the mq_open Function |
| A-1 | Process Control Functions |
| A-2 | P1003.1b Priority Scheduling Functions |
| A-3 | P1003.1b Clock Functions |
| A-4 | Date and Time Conversion Functions |
| A-5 | P1003.1b Timer Functions |
| A-6 | BSD Clock and Timer Functions |
| A-7 | P1003.1b Memory-Locking Functions |
| A-8 | System V Memory-Locking Function |
| A-9 | P1003.1b Asynchronous I/O Functions |
| A-10 | POSIX Synchronized I/O Functions |
| A-11 | BSD Synchronized I/O Function |
| A-12 | P1003.1b Message Functions |
| A-13 | P1003.1b Shared-Memory Functions |
| A-14 | P1003.1b Semaphore Functions |
| A-15 | POSIX 1003.1b Realtime Signal Functions |
| A-16 | Signal Control and Other Signal Functions |
| A-17 | sigsetops Primitives |
| A-18 | Process Ownership Functions |
| A-19 | Input and Output Functions |
| A-20 | Device Control Functions |
| A-21 | System Database Functions |
| Index |