From: Marcos D. de A. <ma...@cs...> - 2008-10-01 07:28:33
|
Hi All, adding something to a previous discussion about the way simjava2 manages the threads (i.e. entities), I think that you have probably faced the same problems. As simjava2 restarts all entities that have events scheduled for the same time (i.e. a clock tick), it may happen that both a GridResource and its policy have two separate events to be handled at the same simulation time. The event received by the GridResource may be a gridlet submission whereas the event received by the policy may be an internal event used to update some list. (From sim_system.run_tick()) : int entities_size = entities.size(); for (int i=0; i < entities_size; i++) { ent = (Sim_entity)entities.get(i); if (ent.get_state() == Sim_entity.RUNNABLE) { ent.restart(); num_started++; } } If you have used java 5's features such as "for(Object obj : Iterable) {" you will notice that if you try to iterate an iterable object in the gridletSubmit method and update it somewhere else, you are likely to receive a ConcurrentModificationException. The reason is that the methods: public void gridletSubmit(Gridlet gl, boolean ack); public void gridletCancel(int gridletId, int userId); public void gridletPause(int gridletId, int userId, boolean ack); public void gridletResume(int gridletId, int userId, boolean ack); public int gridletStatus(int gridletId, int userId); public void gridletMove(int gridletId, int userId, int destId, boolean ack); public void processOtherEvent(Sim_event ev) are not synchronised. This way, GridResource may be invoking some of the policie's method running in one thread while the policy is updating the list in another thread. Although this may look obvious, a user trying to implement its policy might get quite puzzled about it. I am also wondering, another problem is that the results may look different if a simulation is run on different computers with different numbers of cores. 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... ------------- "No serious sociologist any longer believes that the voice of the people expresses any divine or specially wise idea. The voice of the people expresses the mind of the people, and that mind is made up for it by the group leaders in whom it believes and by those persons who understand the manipulation of the public opinion. It is composed of inherited prejudices and symbols and cliché's and verbal formulas supplied to them by the leaders." Edward L. Bernays |