Repository navigation
fix(kernel): a stop waits for the step in flight and ends it - #588
Open
EnriqueParodi wants to merge 3 commits into
Open
EnriqueParodi wants to merge 3 commits into
EnriqueParodi wants to merge 3 commits into
Conversation
A component can ask the kernel to stop from inside a virtual-time step, while the clock driving that step still has calls to make. doStop stopped the components under those calls, so the step's flush waited for an answer from a component already gone, and the process never exited. A step gate now stands in front of the clock calls. The stop closes it, waits for the call under way, and flushes the step that call left owing; only then do the components stop, so no call is ever left waiting for one that has gone. advanceTimeDrainInputsAndUpdate and flushVirtualTime report this to their caller, which takes no step and names no next one once the kernel is stopping. The test drives three components in separate groups, holding the step open until the stop has reached the component that asked for it. It requires the step the stop was asked in to be the last any component took, and to have been flushed.
The comments explained the change rather than the code, in the past tense, and repeated the step gate's reason in three places. The reason is stated once now, beside the members it guards, and the names carry the rest.
The gate notified every waiter each time a clock call ended, which is once per step on the kernel's own path. Only finishStepInFlight waits, and only the one thread that gets through doStop reaches it, so there is never more than one.
EnriqueParodi
marked this pull request as ready for review
November 10, 2026 13:16
| } | ||
|
|
||
| public: | ||
| std::shared_ptr<Stepper> object; |
There was a problem hiding this comment.
❌ misc-non-private-member-variables-in-classes ❌
member variable object has public visibility
|
|
||
| public: | ||
| std::shared_ptr<Stepper> object; | ||
| std::shared_ptr<sen::ObjectSource> source; |
There was a problem hiding this comment.
❌ misc-non-private-member-variables-in-classes ❌
member variable source has public visibility
| public: | ||
| std::shared_ptr<Stepper> object; | ||
| std::shared_ptr<sen::ObjectSource> source; | ||
| std::atomic<int> steps {0}; |
There was a problem hiding this comment.
❌ misc-non-private-member-variables-in-classes ❌
member variable steps has public visibility
| #include "sen/kernel/test_kernel.h" | ||
|
|
||
| // generated code | ||
| #include "stl/sen/kernel/kernel_objects.stl.h" |
There was a problem hiding this comment.
❌ misc-include-cleaner ❌
no header providing "sen::kernel::RunMode" is directly included
Suggested change
| #include "stl/sen/kernel/kernel_objects.stl.h" | |
| #include "stl/sen/kernel/basic_types.stl.h" | |
| #include "stl/sen/kernel/kernel_objects.stl.h" |
| { | ||
| // The threads cannot be joined, so this ends the binary here. The counters say which hang it is: | ||
| // steps at stopStep with the stop asked is this test's, less means the run never got there. | ||
| std::fprintf(stderr, |
There was a problem hiding this comment.
❌ hicpp-vararg ❌
do not call c-style vararg functions
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
kernel-stop-in-step: a component asking the kernel to stop from inside a virtual-time step could hang the process forever.
doStop stopped the components while the clock driving the step still had calls to make, so the step's flush waited for an answer from a component already gone. A step gate now stands in front of the clock calls: the stop closes it, waits for the call under way, flushes the step that call left owing, and only then stops the components.