Preface

To achieve great things, two things are needed: a plan, and not quite enough time.”

—Leonard Bernstein

AS this book is being written, the age of real-time programming, especially with Java, has only begun. In the near future, however, we predict that real-time Java—namely, the Java Real-Time System (Java RTS) from Sun Microsystems—will be used predominantly in real-time application areas, such as software in the financial world, critical control systems, manufacturing lines, military and other government systems, and so on. This prediction arrives in the shadow of a time when Java was once considered “too slow” to be used in the development of mission-critical and other enterprise systems.

However, just as Java had proven quickly to the world that it could perform well enough for even the most demanding enterprise systems, Java RTS is actively proving itself in the real-time space. Gone is the necessity for complicated, specialized, real-time languages and operating environments; Java RTS brings all of the productivity and familiarity of the Java language to systems with real-time requirements. Literally decades of research, knowledge, and advancement found in the real-time discipline is now at the fingertips of every Java developer, requiring little more understanding than that of a new library of classes.

It was in the late ’90s that Greg Bollella had the idea for a real-time version of Java while in Chicago on a business trip. Soon after, JSR-001 was started and the specification was in its early stages. The specification was led by Greg, and involved many of the best minds involved in real-time scheduling theory, microprocessor design, embedded systems design, and language design. In the end, a specification was finalized that defines how Java is to behave in the real-time space, and Java RTS was built to conform to it and make it a reality.

Defining “Real-Time”

Although the first chapter of this book discusses and defines real-time systems thoroughly, it’s best to set the stage early and agree upon a precise definition. With real-time programming, the overall goal is to ensure that a system performs its tasks, in response to real-world events, before a defined deadline. Regardless of whether that deadline is measured in microseconds or days, as long as the task is required to complete before that deadline, the system is considered real-time. That simple definition is the foundation for an entire discipline in computer science, with years of research and development within both academia and industry.

To put it differently, the time delay from when a real-world event occurs (such as an object passing over a sensor, or the arrival of a stock market data-feed tick) to the time some code finishes processing that event should be bounded. The ability to meet this deadline must be predictable and guaranteed, all the time, in order to provide the determinism needed for a real-time system.

Meeting the requirements for real-time systems can be so demanding that dedicated programming languages, operating systems, frameworks, and scheduling algorithms have been created. Distinct areas of study, sets of tools, and even entire companies have been formed to solve real-time problems. It is precisely for these reasons that the Sun Java Real-Time System has been created.

The Real-Time Specification for Java

The Java Real-Time System from Sun is a 100%-compatible implementation of the Real-Time Specification for Java (RTSJ). The RTSJ is also known as JSR-001; the very first Java specification request (JSR) for which the entire Java Community Process (JCP) was created. Real-time Java is the first of many firsts, and has paved a way for not only what it was intended (real-time programming in Java), but also for the foundation of Java’s growth in terms of language features through the creation of the JCP.

The RTSJ is a standard that defines how Java applications are to behave in a real-world environment. It was created by experts in many disciplines (i.e., embedded systems design, language design, operating system design, processor design, real-time scheduling theory, and so on), from many companies, from all around the world—a truly global effort. The number one goal, other than defining how real-time behavior could be achieved with Java, was to not change the Java language at all. Meeting this goal was important to ensure that Java, as the thousands of developers know it today, can be used in a real-time context, with no compromise.

In order for an implementation of Java to call itself “real-time,” it must conform to the RTSJ. Anything else is non-standard, as defined by the Java community as a whole. This ensures that developing a real-time application in Java will work with any RTSJ-compliant JVM, and will behave as defined in a real-time environment, without the need for specialized extensions or hardware. Anything else would violate the very principles Java was founded upon. Java RTS is compliant with the RTSJ, and is therefore standards-based.

This Book’s Focus and Audience

Although other books have been written about the RTSJ, this book focuses on Java RTS, its APIs, and what it takes to build real-time applications in Java. The intent is to provide you with practical knowledge and examples of how to build real-time applications with Java. Wherever possible, key teachings will be presented through the use of actual working code examples, as well as visual diagrams to make complicated concepts clear.

Although Java RTS is the focus, all of the knowledge gained from this book will be RTSJ-compliant by default. An understanding of the RTSJ is not a prerequisite for this book, but it’s highly recommended that you read this specification since it’s the basis for the material presented herein. You can find the latest specification and related material at http://www.rtsj.org.

This book’s primary audience is comprised of architects and developers (of all levels) who need to build an application with time-critical code. There are different types of developers that this book targets:

• Java developers who are currently building applications with real-time requirements with or without Java RTS

• Java developers who are interested in learning the Java RTS APIs for future projects

• Non-Java real-time application developers who wish to use Java for real-time application development

• Architects and developers who wish to use Java RTS in order to deploy on a general-purpose operating system (as opposed to a specialized operating system, platform, or language)

To each of these developers, Java RTS and the RTSJ represent freedom from specialized hardware, operating systems, and languages. When this freedom is coupled with Java’s productivity gains and large developer community, Java RTS represents a wise business choice as well, and a potentially huge savings in money.

Structure of the Book

This book has been broken down into three main sections:

Part I—Real-Time Computing Concepts: The first part lays the groundwork for using Java RTS. It clearly defines the concept of real-time in the computing world, and discusses many of the theories of real-time application design and development.

This includes Chapters 1 through 4.

Part II—Inside Java RTS: The second part dives deep into the Java RTS APIs, providing ample code samples to illustrate the inner workings and use of Java RTS. You’ll gain a deeper understanding of the RTSJ principals, as applied to real problems.

This includes Chapters 5 through 10.

Part III—Using Java RTS: The third and final part discusses a comprehensive case study where Java RTS has been used to solve actual real-time system problems, as well as tools used to develop and debug Java RTS applications.

This includes Chapters 11 and 12.

The chapter breakdown of this book is as follows:

Chapter 1—Real-Time for the Rest of Us: This chapter provides a thorough definition of real-time systems, and then compares them to high-performance systems and those with high-throughput requirements. Other key terms, such as predictability, jitter, latency, and determinism are defined and explored. The second half of this chapter contains a high-level discussion of real-time scheduling. Analogies, descriptions, and visuals will be used to bring the concepts down to earth; at a level where the average programmer should be comfortable.

Chapter 2—Real-Time and Java SE: This chapter explores the use of standard Java in real-time environments. Issues that arise, such as the execution of the Java garbage collector, and the just-in-time compiler, will be discussed as sources of trouble. The chapter discusses, in detail, garbage collection in Java SE 6 and the forthcoming Java SE 7, and concludes with an overview of real-time garbage collection algorithms.

Chapter 3—The Real-Time Specification for Java: The RTSJ defines how Java should behave in the real-time space. In fact, the RTSJ was the first Java Specification Request (JSR), and a big reason why the Java Community Process (JCP) was formed. The specification, led by Greg Bollella, included experts from around the globe, from both academia and industry, and is known today as a standard for real-time Java development. This chapter provides a brief overview of the RTSJ.

Chapter 4—The Sun Java Real-Time System: This chapter begins our exploration of real-time Java with a discussion of Java RTS, Sun’s product that implements the RTSJ. Reading this chapter will help you get up and running with a working Java RTS system on either Solaris or Linux.

Chapter 5—Threads, Scheduling, and the New Memory Models: As the first chapter to dive deep into the Java RTS APIs, the focus of the chapter is on the new threading models available to you, along with the different memory models introduced with the RTSJ.

Chapter 6—Synchronization: This chapter explores how thread synchronization is changed in Java RTS. It also dives into the internals to examine some of the enhancements made in the Java VM to minimize latency when synchronizing multiple threads’ access to shared resources.

Chapter 7—The Real-Time Clock API: Java RTS provides support for high-resolution timers, and deterministic timer objects. In this chapter, we’ll examine the real-time Clock API, and how timer objects can be created for deterministic operation.

Chapter 8—Asynchronous Events: Java RTS gives you more control over how work is scheduled in a system. This chapter examines the classes that are available to you to control how events are handled in your real-time application.

Chapter 9—Asynchronous Transfer of Control and Thread Termination: In this chapter, we’ll explore the fine-grained control Java RTS provides for schedulable objects in terms of transferring control from one method to another, and terminating tasks.

Chapter 10—Inside the Real-Time Garbage Collector: This chapter dives deep into the inner workings of the real-time garbage collector, and describes how it operates. Having a solid understanding of how the RTGC works, how it affects your system, and how it can be tuned will help you build more efficient Java RTS applications.

Chapter 11—An Equities Trading System: This chapter explores the use of Java RTS in a financial application that closely mimics those used by traders, investment banks, and exchanges in the world of finance. In the world of investing, banking, and finance, latencies due to garbage collection introduce the risk of missing important market events. The resulting delays translate directly to lost money in these markets.

Chapter 12—Java RTS Tools: Here, we discuss the tools available to develop and debug Java RTS applications.

Staying Up-to-Date

No book is ever complete, and important technologies such as Java RTS aren’t static—they constantly evolve. Check the web site, http://www.ericbruno.com/ realtime, for updates and extra content, as well as the complete code for the samples and many of the case studies. We’ll also keep you up to date on changes to the RTSJ, as well as to Sun’s implementation, Java RTS.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.25.74