Skip to content

Conversation

@Gurankio
Copy link

@Gurankio Gurankio commented Dec 24, 2025

Comprehensive unit tests were added for the core package.
Several bugs were identified and fixed during testing, mainly addressing subtle concurrency issues and unexpected global state that could lead to inconsistent behavior or crashes.

Key Fixes

  • EventQueue running flag
    Previously, EventQueue only partially checked the running flag, which could cause inconsistent state or simulation crashes.
    Fixed by adding overloads to ensure no invalid states occur (not exhaustive).

  • Event serial numbering
    Serial numbers started from 0. After calling schedule (adding an event with priority 0), a subsequent scheduleNow (also priority 0) could incorrectly insert as the second event.
    Fixed by introducing a separate serial counter for scheduleNow.

  • Incomplete simulation reset
    CloudSim::init did not fully reset the simulation state—specifically, the variables pause, pauseAt, abruptTerminate, and terminateAt retained previous values.
    Fixed by resetting them to their defaults.

  • Unsynchronized access to CloudSim.paused
    Access to CloudSim.paused was not synchronized, even though examples showed it being written to from separate threads.
    Fixed by replacing the polling approach with Object::wait() and Object::notify() for thread-safe synchronization.

Additional Notes

  • Rewrote CloudSim::getSimulationCalendar for clarity.
  • Did not test the SimEntity::send family since NetworkTopology is not part of the core package.

- EventQueue running flag was not checked in all methods
- Event serial numbering did not behave as expected in all cases
- Incomplete simulation reset, not all global state was reset on an init call
- Unsynchronized access to CloudSim.paused
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.

1 participant