Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ConcurrentModificationException in CloudSim.runClockTick() #191

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

swghosh
Copy link
Contributor

@swghosh swghosh commented Nov 20, 2024

Fixes: #187

ConcurrentModificationException can occur when SimEntity changes it's own state during run() depending upon implementation in between the Simulation clock ticks. This causes to break the simulator run similar to what happens today in CloudSimExample8. Although, this change fixes the said example it now allows users to write their SimEntity implementation in a way that during processEvent / run etc. during the lifecycle of the entity processing it can change it's own state, i.e. change the values of it's linked variables; from a design perspective of the simulator this may/may not be allowed.

In case of CloudSimExample8, the GlobalBroker implementation changes it's state during the course of it's run which today causes the exception to occur so alternative pathway is that we might need to fix the Broker implementation.

when SimEntity changes it's own state during run() / processEvent() depending upon implementation

Signed-off-by: Swarup Ghosh <[email protected]>
@swghosh
Copy link
Contributor Author

swghosh commented Nov 20, 2024

cc: @Astabol @Raove

Copy link

@Raove Raove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the error and the example runs correctly now. Code is basically the same, it just Calls the entity at location i instead of using the entity that can change.

@deRemo
Copy link
Member

deRemo commented Nov 27, 2024

Hi, thanks for the pull request!

I digged through the commits myself while working on the stable version of 7G (swill in WIP), and found out that what you propose is actually the original of the event loop, which was then modified in 3d0d14a (without a regression test :( ), thus introducing the bug mentioned in #187.

Anyhow, I'll accept your commit, thanks for the contribution :)

Copy link
Member

@deRemo deRemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@deRemo deRemo merged commit 0400960 into Cloudslab:master Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudSimExample8.java is not working
3 participants