1 overview assignment 7: hints distributed objects assignment 6: solution living with a garbage...

8
1 Overview Assignment 7: hints Distributed objects Assignment 6: solution Living with a garbage collector

Upload: nathaniel-mathews

Post on 15-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

1

Overview Assignment 7: hints

Distributed objects Assignment 6: solution

Living with a garbage collector

Page 2: 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);

}

Page 3: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

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

Page 4: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

4

Overview Assignment 7: hints

Distributed objects Assignment 6: solution

Living with a garbage collector

Page 5: 1 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

Page 6: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

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).

Page 7: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

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.

Page 8: 1 Overview Assignment 7: hints  Distributed objects Assignment 6: solution  Living with a garbage collector

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