MALL JAVA PO       January 16, 2006

Instructions for Chameneos source code
--------------------------------------
The file p_chameneos.adb contains the Ada procedure P_Chameneos illustrating some peer to peer synchronization problems

It can be run by entering the following Unix shell commands :

gnatmake p_chameneos.adb
./p_chameneos

This directory contains 10 files which are Ada library units:
p_chameneos.adb
p_id_chameneos.ads
mall.adb         the version is to be found in one of the companion directory CHAMENEOS_PO_R_ADA or CHAMENEOS_PO_R_JAVA
mall.ads
generic_lock.adb
generic_lock.ads
p_colour.adb
p_colour.ads
protected_machine.adb
protected_machine.ads

--------------------------------------
About this version
--------------------------------------

In CHAMENEOS_PO_R_JAVA, the  MALL version is simulating Java solution with standard Java monitor semantics ----------------------

This implementation is safe since this Java like implementation is defensive using MustWait
MustWait forbids a newcommer to overcome the waiting partner

This version of the mall is implemented with a protected object named Cooperation_Synchro.

The Java wait operation is here an entry call with a barrier named NotifyAll

The Java synchronized method is simulated by Cooperation_Synchro
Score is an in out parameter indicating the stage reached by the caller
Score = 0 is the first request
Score = 1 when the first partner has registered and waits for the arrival of the second
Score = 2 when the partner Id is returned

Data are used to record the history of the server behaviour  

First_Call : Boolean := True;         -- when the call is the first call of a pair of Chameneos
MustWait : Boolean := True;          -- Java defensive programming forbidding a newcommer to overcome the waiting partner
A_Chameneos   : Id_Chameneos; -- name of the first visitor
B_Chameneos   : Id_Chameneos; -- name of the second visitor

MustWait forbids the execution of the entry Cooperate  by a third visitor until the first visitor which has been requeued to the entry Wait has got the monitor lock and registered the name of its partner.

In CHAMENEOS_PO_R_ADA, the  MALL version is simulating Java solution with non standard Java monitor semantics i.e. with a monitor semantics similar to Ada one, giving priority to signalled processes which were waiting in the monitor queue