From: Marcos D. de A. <ma...@cs...> - 2009-02-14 03:18:35
|
Dear Giancarlo, > I think the exception is brought by a race condition between a call to > gridletSubmit() method of SpaceShared class (or whatever class extends > AllocPolicy) made by GridResource thread and events treated in the > body > of SpaceShared thread You are right, the race condition is probably there. The problem is that each entity in GridSim is a thread. Simjava2 works with two event queues, namely the future event queue and the deferred event queue. Every time Sim_system class reads the queue of future events (i.e. at each clock tick), it puts all the next events to be handles in the deferred queue. If there are multiple events scheduled for the very same simulation time, they will all be placed in the deferred queue. After that, Sim_system wakes up all the threads to consume events. The problem arises when there are two events in the deferred queue, one for GridResource and another for the policy, both for the same time and both will result in making the entities access internal variables of the policy. This problem is noticed more often if you use the send method without the port because in this case there will be no network. When you use the send with the port, the network features introduce very small delays between the events, which will prevent them from being scheduled at exactly the same time, so you will not notice the problem. Yes, this is a bug and you are not the first one to experience this problem. I think people had not noticed it before because they were using Java 1.4. One solution to this problem would consist in making GridResource send an event to the policy instead of calling a method from it. By the way, this is the approach suggested in SimJava2's documentation. The other solution, if you are using the the source code of GridSim instead of the jar files, is to add some synchronisation to the allocation policy. Regards, Marcos Marcos Dias de Assuncao Grid Computing and Distributed Systems (GRIDS) Laboratory Department of Computer Science and Software Engineering The University of Melbourne, Australia Email: ma...@cs... ------------- "It is well enough that people of the nation do not understand our banking and monetary system, for if they did, I believe there would be a revolution before tomorrow morning." Henry Ford |