Fix serial putchar newline deadlock#306
Merged
Ivan-Velickovic merged 1 commit intomainfrom Jan 30, 2025
Merged
Conversation
5a65364 to
d6908c5
Compare
079bbdc to
23a7090
Compare
d6908c5 to
b716a8c
Compare
23a7090 to
0df8f55
Compare
b716a8c to
ac14b64
Compare
0df8f55 to
ea468fb
Compare
ac14b64 to
50d849a
Compare
ea468fb to
42d5e9a
Compare
Signed-off-by: Courtney Darville <courtneydarville94@outlook.com>
50d849a to
dbc195d
Compare
Ivan-Velickovic
approved these changes
Jan 30, 2025
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.
While making recent changes to the serial subsystem, I notice a potential deadlock in the
_sddf_putcharfunction.Prior to this PR, the function only signals the
TX_CHif the queue is full after inserting a character, or if the character inserted was theFLUSH_CHAR. However, the function only actually inserts a character into the queue if it is not full, or in the case of a\ncharacter, the queue has space for 2 characters.This means that if the queue only has space for one character, and a
\nis attempted to be inserted, the function will immediately return without signalling, and there is no guarantee the function signalled on its previous invocation. This is a potential deadlock, as the virtualiser has potentially not yet been signalled for the remaining characters in the queue, and the system is dependent on the client enqueuing another non\ncharacter for a signal to occur.This PR fixes this deadlock situation by signalling if either the queue is full, the flush character is seen, or if the queue is one from full, which eliminates the scenario that a signal is missed. It also stops any characters from being enqueued if the queue is 1 from full, to prevent against accidental double signals which would interfere with the multiplexing.
Merge after #305.