80 likes | 184 Views
Overview. Assignment 7: hints Distributed objects Assignment 6: solution Living with a garbage collector. A7 - Distributed Objects. public interface RemoteFS { public byte[] readFile(String filename); public void writeFile(String filename, byte[] content); }.
E N D
Overview • Assignment 7: hints • Distributed objects • Assignment 6: solution • Living with a garbage collector
A7 - Distributed Objects public interface RemoteFS { public byte[] readFile(String filename); public void writeFile(String filename, byte[] content); } 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/
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
Overview • Assignment 7: hints • Distributed objects • Assignment 6: solution • Living with a garbage collector
A6 Ex1 – Finalizers • Finalizers are not executed by the GC: • takes time • could block • Resuscitation: • Finalizers are executed only once • The 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
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).
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 pointer • at GC time we check for all the marked cards if such an old-young reference was created.
A6 Ex3 – Weak pointers • .NET • big structures that can be easily reconstructed • ex: file hierarchy, file buffers, I/O buffers • Java • object monitoring (AB) • we can link them without blocking collection • an object (A) receives a notification when the pointed-to object (B) is removed