back to API     back to index     back to guided tour index     prev     next  

The readers-writers

The readers and the writers want to access the same data. In order to allow concurrency while ensuring the consistency of the readings, accesses to the data have to be synchronized upon a specified policy. Thanks to ProActive, the accesses are guaranteed to be allowed sequentially.

The implementation with ProActive uses 3 active objects : Reader, Writer, and the controller class (ReaderWriter).

 

1. start the application

using the readers script

ProActive starts a node (i.e. a JVM) on the current machine, and creates 3 Writer, 3 Reader, a ReaderWriter (the controller of the application) and a ReaderDisplay, that are active objects.

a GUI is started that illustrates the activities of the Reader and Writer objects.

2. look and check the effect of different policies : even, writer priority, reader priority

What happens when priority is set to "reader priority" ?

 

3. look at the code for programming such policies

in org.objectweb.proactive.examples.readers.ReaderWriter.java

More specifically, look at the routines in :

public void evenPolicy(org.objectweb.proactive.Service service)

public void readerPolicy(org.objectweb.proactive.Service service)

public void writerPolicy(org.objectweb.proactive.Service service)

Look at the inner class MyRequestFilterm that implements org.objectweb.proactive.core.body.request.RequestFilter

How does it work?

 

4. Introduce a bug in the Writer Priority policy

For instance, let several writers go through at the same time.

- observe the Writer Policy policy before recompiling

- recompile (using compile.sh readers or compile.bat readers)

- observe that stub classes are regenerated and recompiled

- observe the difference due to the new synchronization policy : what happens now?

- correct the bug and recompile again ; check that everything is back to normal