core package unit tests and bug fixes #221
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Comprehensive unit tests were added for the
corepackage.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,
EventQueueonly 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 callingschedule(adding an event with priority 0), a subsequentscheduleNow(also priority 0) could incorrectly insert as the second event.Fixed by introducing a separate serial counter for scheduleNow.
Incomplete simulation reset
CloudSim::initdid not fully reset the simulation state—specifically, the variablespause,pauseAt,abruptTerminate, andterminateAtretained previous values.Fixed by resetting them to their defaults.
Unsynchronized access to
CloudSim.pausedAccess to
CloudSim.pausedwas not synchronized, even though examples showed it being written to from separate threads.Fixed by replacing the polling approach with
Object::wait()andObject::notify()for thread-safe synchronization.Additional Notes
CloudSim::getSimulationCalendarfor clarity.SimEntity::sendfamily sinceNetworkTopologyis not part of thecorepackage.