1 overview assignment 7: hints distributed objects assignment 6: solution living with a garbage...
TRANSCRIPT
1
Overview Assignment 7: hints
Distributed objects Assignment 6: solution
Living with a garbage collector
2
A7 - Distributed Objects Imagine a distributed FileSystem as a
distributed object of type:
Write a small client/server Application using Java/RMI
http://java.sun.com/docs/books/tutorial/rmi/
public interface RemoteFS {public byte[] readFile(String filename);public void writeFile(String filename, byte[] content);
}
3
A7 - RMI Client operates on Interface, Implementation on
a remote Server
It should be possible to use the client program in the following way: java RemoteFSClient <filename> to read a File
echo <anything> | java RemoteFSClient <filename> to write a file
cat <fromFile> | java RemoteFSClient <toFile> copy
4
Overview Assignment 7: hints
Distributed objects Assignment 6: solution
Living with a garbage collector
5
A6 Ex1 – Finalizers Finalizers are not executed by the GC:
takes timecould block
Resuscitation:Finalizers are executed only onceThe finalizer of a resuscitated object is not run
again (since there is no entry in the finalizer queue)
Finalizers can be re-enabled using ReRegisterForFinalize
6
A6 Ex1 – Finalizers Pointers in finalizers:
Objects referenced in finalizers could be invalid since objects are disposed in no particular order.
Dependencies should be handled by the user (e.g. in a close method).
7
A6 Ex2 – Write barriers To check if we have a pointer from an
older generation to a younger one for each assignment is expensive.we divide the heap in small regions (cards)we mark the enclosing region every time we
update a pointerat GC time we check for all the marked cards
if such an old-young reference was created.
8
A6 Ex3 – Weak pointers .NET
big structures that can be easily reconstructedex: file hierarchy, file buffers, I/O buffers
Javaobject monitoring (AB)
we can link them without blocking collection an object (A) receives a notification when the
pointed-to object (B) is removed