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

Release IRQ_HANDLERS' lock before running deferred jobs #85

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions kernel/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ pub fn attach_irq(irq: u8, f: Box<dyn FnMut() + Send + Sync + 'static>) {
}

pub fn handle_irq(irq: u8) {
let handler = &mut IRQ_HANDLERS.lock()[irq as usize];
unsafe {
(*handler.assume_init_mut())();
{
let handler = &mut IRQ_HANDLERS.lock()[irq as usize];
unsafe {
(*handler.assume_init_mut())();
}

// `handler` is dropped here to release IRQ_HANDLERS's lock since
// we re-enable interrupts just before running deferred jobs.
}

// TODO: Re-enable interrupts to make deferred jobs preemptive.

// So-called "bottom half" in Linux kernel. Execute time-consuming but
// non-critical work like processing packets.
run_deferred_jobs();
Expand Down