Skip to content

Commit

Permalink
Fix deadlock in priority donation code.
Browse files Browse the repository at this point in the history
Drop the spinlock before calling maybe_reschedule_thread.
  • Loading branch information
dbittman committed Nov 8, 2024
1 parent 7f1bd3b commit b7ebdb3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/kernel/src/thread/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl Thread {
self.flags
.fetch_and(!THREAD_HAS_DONATED_PRIORITY, Ordering::SeqCst);
*donated_priority = None;
drop(donated_priority);
if current_priority < self.effective_priority() {
self.maybe_reschedule_thread();
}
Expand Down Expand Up @@ -167,6 +168,7 @@ impl Thread {
*donated_priority = Some(pri);
self.flags
.fetch_or(THREAD_HAS_DONATED_PRIORITY, Ordering::SeqCst);
drop(donated_priority);
if needs_resched {
if let Some(cur) = current_thread_ref() {
if cur.id() == self.id() {
Expand Down

0 comments on commit b7ebdb3

Please sign in to comment.