Overview n Assignment 7 hints Distributed n objects
Overview n Assignment 7: hints ¨ Distributed n objects Assignment 6: solution ¨ Living with a garbage collector 1
A 7 - Distributed Objects n Imagine a distributed File. System as a distributed object of type: public interface Remote. FS { public byte[] read. File(String filename); public void write. File(String filename, byte[] content); } Write a small client/server Application using Java/RMI n http: //java. sun. com/docs/books/tutorial/rmi/ n 2
A 7 - RMI n Client operates on Interface, Implementation on a remote Server n It should be possible to use the client program in the following way: ¨ java Remote. FSClient <filename> to read a File ¨ echo <anything> | java Remote. FSClient <filename> to write a file ¨ cat <from. File> | java Remote. FSClient <to. File> copy 3
Overview n Assignment 7: hints ¨ Distributed n objects Assignment 6: solution ¨ Living with a garbage collector 4
A 6 Ex 1 – Finalizers n Finalizers are not executed by the GC: ¨ takes time ¨ could block n 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 Re. Register. For. Finalize 5
A 6 Ex 1 – Finalizers n 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). 6
A 6 Ex 2 – Write barriers n 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. 7
A 6 Ex 3 – Weak pointers n . NET ¨ big structures that can be easily reconstructed ¨ ex: file hierarchy, file buffers, I/O buffers n Java ¨ object monitoring (A B) we can link them without blocking collection n an object (A) receives a notification when the pointed-to object (B) is removed n 8
- Slides: 8