(Not too) Real-Time JVM (Progress Report) Dec. 28, 2001 Jong-Koo,Lim RealTimeSystems Lab
Contents Goal Related Works Java Virtual Machine Real-Time Java System Architecture Inside Java Virtual Machine Problems with typical JVM Real-Time Java Seven Enhanced Areas
Goal Design and Implementation of Real-Time Extensions in Java Virtual Machine
Related Works Java Virtual Machine Real-Time Java Current JVM : Kaffe, Hotspot, CVM, KVM Platform : Real-Time Linux Real-Time Java Java is not appropriate for real-time software It is possible to support real-time software if java has any special implementation Seven Enhanced Areas
Java Virtual Machine System Architecture Inside Java Virtual Machine Problems with typical JVMs
System Architecture Class Libraries Java Threads Native Threads Java Virtual Machine Native Methods (Real-Time) Operating System Processor and Other Hardware
Inside a Java Virtual Machine Find and load referenced class in the CLASSPATH Java Application ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count cp_info constant_pool[ ]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 fields_count; u2 methods_count; u2 attributes_count; } Class Libraries Class Loader Execution Engine performs the final translation - Bytecode to native opcode Difference engine types - Bytecode interpreter - Just-in-time compiler - Hybrid Bytecode Verifier Native Methods Execution Engine Run-time Data Area Garbage Collector Method Area heap Java Stacks PC Registers Native Method Stacks Run-time Data Areas Simplest Garbage Collector - Incremental Garbage Collector (Real-Time) Operating System 7 RealTimeSystems Lab
Garbage Collection Two basic sequence Two basic approach Detect garbage objects Reclaim the heap space Two basic approach Reference-counting garbage collector a reference count is maintained for each object Tracing garbage collector trace out the graph of object references, starting with the root nodes. class A { ….. ; } A a1 = new A(); A a2 = new A(); A a3 = a1; // a1’s rc = 2 A a4 = a1; // a1’s rc = 3 a2 = null; /* a2’s rc =0, so, a2 is garbage */
Inside a Java Class Files - Class File Header 000000 CAFEBABE magic = ca fe ba be 000004 0003 minor version = 3 000006 002d major version = 45 Constant Pool 000008 0175 292 constants 00000a 0A006600AB 1. Methodref class #102 , name-and-type #171 00000f 09006500AC 2. Fieldref class #101, name-and-type #172 (the following is omitted) Constant Pool Tag Class index Constant Pool Entry
Oolong (Assembly Language for JVM) DumpClass : => Display and Analyze ‘class file’ in a bytecode unit Gnoloo : *.class => *.j Oolong : *.j => *.class
Problems with typical JVM Too Big A full-featured JVM is huge(~500k of ROM) In addition there are class libraries, heap, etc Too Slow Bytecode interpretation Run-time checks Too Unpredictable Default garbage collectors are not very good in RTS
Real-Time Java (next work) Seven Enhanced Areas Thread Scheduling and Dispatching Memory Management (Garbage Collector) Synchronization and Resource Sharing Asynchronous Event Handling Asynchronous Transfer of Control Asynchronous Thread Termination Physical Memory Access