Make halted a flag, not a counter
#582
Merged
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.
ProbeCore::haltedis currently an integer value. Each timehalt()is called, we increment the counter, only actually halting when it's initially zero. Similarly,run()decrements the counter, only actually starting the core when the counter reaches 0 again. This logic resembles that of a reentrant mutex, a famously hard-to-misuse primitive.This is causing problems in
reset_and_halt, in combination with #577:reset_and_haltafter programming starts from an already-halted system, sorun()decrements the counter back to 0 and resumes the processor.reset_and_haltagain. In this case, the chip is running, sorun()decrements the counter from 0, which causes a panic.I don't think the counter behavior is necessary. We switched
haltedfrombooltou32in 6877a7a along with anunhalted_reads: boolflag; however, we have since torn out that flag (1b2e361) without switchinghaltedback to abool.