Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: Check for interrupts and deferred calls #1808

Merged
merged 1 commit into from May 1, 2020

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Apr 29, 2020

Pull Request Overview

This pull request changes the do_process loop to break (and stop running a process) if either:

  • There is a pending interrupt
  • There is a pending dynamic deferred call

Before, this only happened on a pending interrupt.

Without this change, applications take priority over pending dynamic deferred calls. This is most noticeable with virtualized uart. If an app calls a syscall that tries to transmit a buffer over uart, the virtual uart mux enqueues a deferred call. That is not an interrupt, so the process loop continues and likely the process may be re-executed. The deferred call will not be executed until the process yields or exhausts its timeslice.

Testing Strategy

I found this on the arty-e21 board which does not have a systick implementation. I tried to use strace, and it didn't display anything. The board turned out to be crashing, so deferred calls were never serviced.

If you want to see this on hail:

  1. Modify sched.rs to disable the systick.
  2. Enable strace in the kernel.
  3. Comment out the debug!() line in main.rs (the UART interrupt from that seems to make things work).
  4. Run the whileone app.

The strace printouts won't happen. If you use process console to generate an interrupt then they will get printed.

TODO or Help Wanted

n/a

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make formatall.

It is not enough to stop executing apps for interrupts, we must also
stop if there are any deferrred calls pending.
Copy link
Member

@lschuermann lschuermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

So within my first contribution I already managed to introduce a race condition and missed this one. Wondering what's to come next. 😆

Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

I think this is good as an immediate fix. It might be nice as part of the scheduler work to expose an understanding of "real" interrupts and "synthetic" interrupts (these) to the scheduler; but we can cross that bridge when we come to it.

@bors
Copy link
Contributor

bors bot commented May 1, 2020

Build succeeded:

@bors bors bot merged commit 275fcc6 into master May 1, 2020
@bors bors bot deleted the kernel-loop-deferred-call branch May 1, 2020 17:01
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.

None yet

3 participants