javolution rtsd
DESCRIPTION
Javolution project for RTSD (university project)TRANSCRIPT
![Page 1: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/1.jpg)
Javolution
Real-Time System Design project,Stoenescu Serban
![Page 2: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/2.jpg)
"The ability to simplify means to eliminate the unnecessary so that the necessary may speak."
Hans Hoffmann
![Page 3: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/3.jpg)
What is Javolution?● Javolution is a Java API for real-time software
systems● Real-time systems imply:
● Higher execution speed● Time predictability
![Page 4: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/4.jpg)
Advantages ● Some classes are easier to use than standard
classes in some SDKs or APIs.● Example: „You don't need to guess the capacity
of a TextBuilder, FastTable or a FastMap, their size expand gently without ever incurring expensive resize/copy or rehash operations (unlike StringBuilder, ArrayList or HashMap). „ [1]
![Page 5: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/5.jpg)
Advantages (continued)● Javolution makes it easy for concurrent
algorithms to take advantage of multi-processors systems. [1]
● Example: Class ConcurrentContext● When a thread enters a concurrent context, it
may call the execute method, then continue with a concurrent thread immediately (or the thread itself if there is no concurrent thread immediately available)
![Page 6: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/6.jpg)
Advantages (continued)● Real-time collection classes● Example: ArrayList (standard) vs. FastTable
(Javolution:● ArrayList may throw
ConcurrentModificationException● FastTable does not throw it (more thread-safe)
![Page 7: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/7.jpg)
Advantages (continued)
● Provides Struct and Union classes for direct interoperability with C/C++;
![Page 8: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/8.jpg)
Advantages (continued)● Most Javolution classes are stateless ([1])● state passed through parameters to methods or
available through Context classes● This design approach makes Javolution and
any product based on Javolution highly parrallelizable with no need for synchronization
![Page 9: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/9.jpg)
Important Features● Context classes allow true separation of
concerns (eg. logging, performance, etc.)● Testing framework
● Allows assertions on execution time in nanoseconds
● World's fastest and first hard real-time XML marshalling/unmarshalling facility([1])
![Page 10: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/10.jpg)
Example Classes
![Page 11: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/11.jpg)
Context
● This class represents an execution context; they can be associated to particular threads or objects.
● Applications may extend this to facilitate separation of concerns
● Extended by: ● ConcurrentContext (see slide 5)● SecurityContext
![Page 12: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/12.jpg)
SecurityContext● Used for separating security concerns.
Example for addressing security requirements ([1])public static boolean isReadAllowed(Table table) {
SecurityContext policy = SecurityContext.current();
return (policy instanceof DatabaseAccess.Permission) ?
((DatabaseAccess.Permission)policy).isReadable(table) : false;
}
![Page 13: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/13.jpg)
High Performance IO Classes● CharSequenceReader● UTF8ByteBufferReader● UTF8ByteBufferWriter● UTF8StreamReader● UTF8StreamWriter
● Differences between this and standard StreamWriters:– Instances of this class can be reused for different output
streams.– Wrapping using a java.io.BufferedWriter is unnescessary
as instances of this class embed their own data buffers.
![Page 14: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/14.jpg)
The Realtime Package● RealTimeInterface: defines RTSJ safe classes● RealtimeThread: time-predictable threads● Reflection.Constructor and Reflection.Method:
● Achieves some of the features provided by reflection
● Reflection is known to be slow
![Page 15: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/15.jpg)
The javolution.util Package● Includes a lot of Javolution collection classes
that have counterparts in standard Java packages.● Examples:
– FastMap<K,V> - HashMap<K,V>– FastSet<E> - Set<E>– FastTable<E> - ArrayList<E>
![Page 16: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/16.jpg)
The javolution.util Package (continued)
● StandardLog class: represents a specialized logging context forwarding events to a standard logger (java.util.logging.Logger) ([1])
● ReentrantLock: same functionality as standard locks
![Page 17: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/17.jpg)
More features● javolution.xml and subpackages provide fast
XML processing features
![Page 18: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/18.jpg)
Sample Application
![Page 19: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/19.jpg)
Sample application● Application is similar reaction time tests in
driving schools● Used for testing and improving reaction times● User is shown some letters● He is supposed to press a key as fast as he can
if a vocal appears, before it disappears● Otherwise he is not supposed to press anything
![Page 20: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/20.jpg)
Sample application (continued)● Uses RealtimeThread for controlling the output
and measuring reaction times● Also measures delays caused by threads● Uses FastSet to keep records of events
![Page 21: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/21.jpg)
Reaction Time Measurement
![Page 22: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/22.jpg)
Log and Statistics
![Page 23: Javolution rtsd](https://reader034.vdocuments.site/reader034/viewer/2022051323/54b739e84a795966598b458b/html5/thumbnails/23.jpg)
Thread delays measurement (milliseconds)