The scoped-memory feature is central to the Real-Time Specifica- tion for Java. It allows greater control over memory management, in particular the deallocation of objects without the use of a garbage collector. To preserve the safety of storage references associated with Java since its inception, the use of scoped memory is con- strained by a set of rules in the specification. While a program’s adherence to the rules can be partially checked at compile-time, un- decidability issues imply that some—perhaps, many—checks may be required at run-time. Poor implementations of those run-time checks could adversely affect overall performance and predictabil- ity, the latter being a founding principle of the specification.
In this paper we present efficient algorithms for managing scoped memories and the checks they impose on programs. Implementa- tions and results published to date require time linear in the depth of scope nesting; our algorithms operate in constant time. We de- scribe our approach and present experiments quantifying the gains in efficiency.
Designing IA for AI - Information Architecture Conference 2024
Efficient Memory-Reference Checks for Real-time Java
1. Efficient Memory-Reference Checks for Real-time Java
Angelo Corsaro and Ron K. Cytron
Department of Computer Science and Engineering
Washington University
St. Louis, MO, 63130, USA
¡
corsaro, cytron @cse.wustl.edu¢
ABSTRACT 1. INTRODUCTION
The scoped-memory feature is central to the Real-Time Specifica- One of the main hurdles for making Java ¤ ¥£ [1] usable for the
tion for Java. It allows greater control over memory management, development of real-time systems has been the fact it is a garbage-
in particular the deallocation of objects without the use of a garbage collected language. While developers generally like the functional-
collector. To preserve the safety of storage references associated ity provided by garbage collection, they object to those aspects of
with Java ¤ ¥£ since its inception, the use of scoped memory is con- garbage collection that could introduce unpredictable delay into an
strained by a set of rules in the specification. While a program’s application.
adherence to the rules can be partially checked at compile-time, un- At one extreme, some collectors work in a stop the world and
decidability issues imply that some—perhaps, many—checks may collect fashion, in which the garbage collector has to stop all the
be required at run-time. Poor implementations of those run-time running threads before attempting to reclaim dead storage. Other
checks could adversely affect overall performance and predictabil- types of garbage collectors take a less restrictive approach, but most
ity, the latter being a founding principle of the specification. of the precise garbage collectors known in literature [10] are not
In this paper we present efficient algorithms for managing scoped suitable for real-time systems.
memories and the checks they impose on programs. Implementa- Recently, garbage-collection algorithms have been described that
tions and results published to date require time linear in the depth reasonably bound the delay experienced by an application [5, 2].
of scope nesting; our algorithms operate in constant time. We de- However, those algorithms require an extra processor, extra heap
scribe our approach and present experiments quantifying the gains space, or both—luxuries that may not be available on a cost com-
in efficiency. petitive, embedded, real-time system. Thus, the expert group that
designed the Real-Time Specification for Java (RTSJ) [4] decided
Categories and Subject Descriptors to provide a memory management scheme that would allow pro-
grammers to circumvent the garbage collector, giving them control
D.3.3 [Programming Languages]: Language Construct and Fea- over the time at which memory is allocated and reclaimed, while at
tures—dynamic storage management, constraints; D.2.8 [Software the same time retaining the storage-referencing safety properties of
Engineering]: Metrics—complexity measures, performance mea- a garbage-collected language.
sures A programming language with safe storage references denies ac-
cess to storage that is dead or that has been reallocated for other
General Terms purposes. Languages like C++ allow explicit control of object allo-
cation and deallocation, yet they provide no mechanism for check-
Algorithms, Performance, Design
ing safe storage references. If RTSJ had adopted the approach of
C++, then unsafe storage references would go unchecked, violating
Keywords a principle design force for Java ¤ ¥£.
Real-Time Java, Object Oriented Languages, Scoped Memory, Garbage The RTSJ, as described in Section 2, extends the Java memory
Collection, Memory Management model by providing several kinds of memory areas other than the
traditional, garbage-collected heap. These memory areas have dif-
ferent properties in term of the lifetime of objects allocated within
them, and in term of the timing guarantees for object allocation and
deallocation.
In particular, the scoped memory area provides a heap-like area
Sponsored by DARPA under contract F33615-00-C-1697 for object allocation. However, garbage collection does not deter-
mine when objects in a scoped memory area are dead. Instead, the
entire scope can be collected when all threads that have entered the
area (by invoking a particular method on the area) have apparently
Permission to make digital or hard copies of all or part of this work for abandoned the area (by exiting the method invoked to gain entry).
personal or classroom use is granted without fee provided that copies are Unfortunately, a thread that has left a scoped memory area could
not made or distributed for profit or commercial advantage and that copies
yet possess references into that area. Threads could also develop
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific references to scoped memory areas for which they have never for-
permission and/or a fee. mally declared their intention to use.
LCTES’03, June 11–13, 2003, San Diego, California, USA. Thus, the undisciplined use of the RTSJ could lead to dangling
Copyright 2003 ACM 1-58113-647-1/03/0006 ...$5.00.
8. [2] D. F. Bacon, P. Cheng, and V. T. Rajan. A real-time garbage
collector with low overhead and consistent utilization. In
Proceedings of the 30th ACM SIGPLAN-SIGACT symposium
on Principles of programming languages, pages 285–298.
ACM Press, 2003.
[3] W. S. Beebee and M. Rinard. An implementation of scoped
memory for real-time Java. Lecture Notes in Computer
Science, 2211, 2001.
[4] Bollella, Gosling, Brosgol, Dibble, Furr, Hardin, and
Turnbull. The Real-Time Specification for Java.
Addison-Wesley, 2000.
[5] P. Cheng and G. Belloch. A parallel, real-time garbage
collector. ACM SIGPLAN Notices, 36(5):125–136, May
2001.
[6] I. Coorporation. Using the RDTSC Instruction for
Performance Monitoring. Technical report, Intel
Coorporation, 1997.
[7] A. Corsaro and D. C. Schmidt. Evaluating Real-Time Java
Features and Performance for Real-time Embedded Systems.
£
In Proceedings of the¡ ¢ IEEE Real-Time Technology and
Applications Symposium, San Jose, Sept. 2002. IEEE.
[8] A. Corsaro and D. C. Schmidt. The Design and Performance
of the jRate Real-Time Java Implementation. In
R. Meersman and Z. Tari, editors, On the Move to
Meaningful Internet Systems 2002: CoopIS, DOA, and
ODBASE, pages 900–921, Berlin, 2002. Lecture Notes in
Computer Science 2519, Springer Verlag.
[9] GNU is Not Unix. GCJ: The GNU Complier for Java.
http://gcc.gnu.org/java, 2002.
[10] R. Jones and R. Lins. Garbage Collection Algorithms for
Automatic Dynamic Memory Management. Wiley Sons,
New York, 1996.
[11] M. A. d. M.-C. M. Teresa Higuera-Toledano. Dynamic
Detection of Access Errors and Illegal References in RTSJ.
£
In Proceedings of the¡ IEEE Real-Time Technology and
Applications Symposium, San Jose, Sept. 2002. IEEE.
[12] Norman H. Cohen. Type-Extension Type Tests Can Be
Performend In Constant Time. ACM Transactions on
Programming Languages and Systems (TOPLAS), 1991.
[13] M. Tofte and J.-P. Talpin. Region-based memory
management. Information and Computation,
132(2):109–176, Feb. 1997.
[14] J. Whaley and M. Rinard. Compositional pointer and escape
analysis for Java programs. ACM SIGPLAN Notices,
34(10):187–206, 1999.