Build powerful real-time Java platform applications.
Written for experienced Java platform developers, this practical guide provides a solid grounding in real-time programming. Dibble, a member of the RTSJ expert group, starts with an overview of real-time issues unique to the Java platform. He then explains how to use each major feature of the RTSJ.
From broad real-time principles to detailed programming pitfalls, Real-Time Java Platform Programming covers everything you need to know to build effective RT programs. Key topics include:
State-of-the-art information for RT developers:
Java Technology and Real Time. Real-Time Programming Requirements. Java and Embedded Real Time. Definition of Real Time. Precision of Measurement. Consistency. Utility Function Curve. Java's Problem Domain. Real-Time Java's Problem Domain. Summary.
Write Once, Run Anywhere: Maybe. JVM Components. Class Loading. Bytecode Interpreter. Security Manager. Garbage Collector. Thread Management. Input/Output. Graphics. Interpreter Implementation. Standard Interpreter. Optimized Interpreter. JIT. Snippets. Compilation to Independent Process. Native Methods. Compilation to a Native Method. Compilation to the JIT Interface.
Worst-Case Execution of One Instruction. Worst-Case Scenario. Practical Measures. Management of Troublesome Hardware. Managing Demand Paging. Managing DMA. Managing Cache. Managing Address Translation Cache. Managing Interrupts. Effects on the JVM.
Reference Counting. Basic Garbage Collection. Mark and Sweep. Defragmentation. Copying Collectors. Incremental Collection. Incremental Garbage Collection in Practice. Generational Garbage Collection. Intergenerational References. Large Object Store. Real-Time Issues.
Scheduling Terms. Execution Sequences. Preemption. The Seductive Charm of Nonpreemptive Scheduling. Fixed versus Dynamic Priority. Priority Inversion. Why 32 Priorities? Problems with Priority Scheduling.
Underlying Mechanism. Scope of the Scheduler. Some Systems. Earliest Deadline First (EDF). Least Laxity. Periodic Scheduling. Aperiodic Servers. Handling Overload. Timing Is Usually Probabilistic.
Theorems. Liu and Layland's Theorem. A Graphical Approach. Lehoczky, Sha, and Ding's Theorem. Restrictions. Independent Tasks. Deadlines Equal to Periods. Multiprocessor Systems.
A Brief History of Real-Time Java. Major Features of the Specification. Threads and Scheduling. Garbage Collection. Asynchronous Event Handlers. Asynchronous Transfer of Control. Memory Allocation. Memory Access. Implementation. RTSJ Hello World.
The Language Construct. Java Closures. Closure Structure. Closures in the RTSJ. Limitations of Closures. Readability. Local Variables. Constructors. Nesting.
Resolution. The “clock”. HighResolutionTime Base Class. Absolute Time. Relative Time. Rational Time.
Binding a Happening to an Event. Basic Async Event Operation. Async Events without Happenings. Time Triggering. Fault Triggering. Software Event Triggering. Implementation Discussion.
Creation. Scheduling. Inversion Handling. Fixed Priority. Feasibility. Periodic Threads without Handlers. Feasibility Analysis. Periodic Threads with Handlers. Interactions with Normal Threads. Changing the Scheduler.
The Advantage of Non-Heap Memory. The Allocation Regimes. Rules. Mechanisms for Allocating Immortal Memory. Mechanisms for Allocating from Scoped Memory. Allocation Time. Creating Scoped Memory. Allocation Mechanisms. Finalizers. Using Nested Scoped Memory. The Scope Stack (Tree). The DAG. Practical Use of Nested Scopes. Every Nested Scope Involves Two Memory Areas. Pitfalls. Using executeInArea. Using Standard Classes. Using Shared Scoped Memory. The Scope Stack Revisited. Scope Portals. Fine Print. Quick Examples.
Interaction with Scheduler. Rules. Samples. Final Remarks. Notes.
Async Events and the Scheduler. The createReleaseParameters Method. Bound Async Event Handlers. Async Event Handlers and Non-Heap Memory. No-Heap Event Handlers vs. No-Heap Threads. Scheduling. Minimum Interarrival Time. Async Event Handlers and Threads. Special Async Events.
Using Fixed-Object Allocators. Carrier Objects. Limitations. Recycling RT Threads. Recycling Async Event Handlers.
Thread Interrupt in Context. Asynchronous Interrupt Firing. The Timed Class. The interrupt Method. The fire Method. In Summary. Replacement Rules. Rules for Async Exception Propagation. Oblivious catch. Nonmatching doInterruptible. Matching doInterruptible. Internals. Application Handling for Asynchronous Interrupts. Noninterruptible Code. Special Issues for Synchronized blocks. Legacy Code. Use of ATC for Thread Termination.
Physical and Virtual Memory. Physical Memory Manager. Memory Type. Removable Memory. Immortal Physical Memory. Scoped Physical Memory.
Security. Peek and Poke. Get/Set Methods. Mapping. The RawMemoryFloatAccess Class.
Principles of Wait-Free Queues. Constructors. Common Methods. The Wait-Free Write Queue. Methods. Sharing the Wait-Free Queue. The Wait-Free Read Queue. The Extra Constructor. Methods. The Wait-Free Double-Ended Queue. Methods. No-Wait Queues and Memory. Implementation Notes.
Powerful and Easy-to-Use Features of the RTSJ. Real-Time Threads. Periodic Threads. Asynchronous Event Handlers. High-Resolution Time. Happenings. Very Powerful and Dangerous Features of the RTSJ. Simple. Leaky. Viral. Very Powerful and Finicky Features of the RTSJ. Scoped Memory. No-Heap Asynchronous Event Handlers. No-Heap Real-Time Threads. Asynchronously Interrupted Exceptions. Selection of Priorities.
You can treat this book as two closely-related books. Chapters 1 through 7 are background that might help understand the RTSJ. The remainder of the book is about the RTSJ itself. If you already understand real-time scheduling, or you donUt care about scheduling and want to get directly to the code, you can start at Chapter 8 and read from that point on. Other than possibly skipping the first seven chapters, I do not recommend skipping around. Few of the chapters can stand by themselves. After youUve skimmed the book once, it can work as reference material, but I suggest that you start by reading the book sequentially.
This book is intended to serve as part of a set comprising three elements: the RTSJ specification, the reference implementation, and this book. You can find the specification and the reference implementation through www.phptr.com/dibble or www.rtj.org. The preliminary RTSJ document is part of the Addison-Wesley Java Series. It is available in hard copy through your favorite book store. However, the preliminary RTSJ has been superseded by the final, version 1.0, version. At this time, the final specification is only available as downloadable PDF and HTML.
The reference implementation is a complete and usable implementation of the RTSJ for Linux. Almost every example in this book was tested on the reference implementation. I have used the reference implementation on PCs running Red Hat Linux and TimeSys Linux, and it should work with other versions of X86 Linux as well, but the reference implementation relies on the underlying operating system for scheduling, so you will find that features like priority inversion avoidance will depend on the version of Linux you use.
The source code for the reference implementation is available. Some of it is descended from the Sun CVM. That is available under the Sun community source license. The parts of the reference implementation that are not related to Sun code are covered under a less restrictive open source license.
Although the reference implementation is excellent for experimentation, it is not designed for commercial use. It does not take the care with performance or memory use that youUd expect from a commercial product.
You can find links to important web sites, corrections and extensions to this book, and probably other useful things like source code at www.phptr.com/dibble