Skip to content

Commit

Permalink
kmc-solid: Inherit the calling task's base priority in Thread::new
Browse files Browse the repository at this point in the history
Fixes a spawned task getting an unexpectedly higher priority if it's
spawned by a task whose priority is temporarily boosted by a priority-
protection mutex.
  • Loading branch information
kawadakk committed Jan 31, 2022
1 parent 5ab502c commit 09233ce
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions library/std/src/sys/itron/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ impl Thread {
///
/// See `thread::Builder::spawn_unchecked` for safety requirements.
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
// Inherit the current task's priority
let current_task = task::try_current_task_id().map_err(|e| e.as_io_error())?;
let priority = task::try_task_priority(current_task).map_err(|e| e.as_io_error())?;

let inner = Box::new(ThreadInner {
start: UnsafeCell::new(ManuallyDrop::new(p)),
lifecycle: AtomicUsize::new(LIFECYCLE_INIT),
Expand Down Expand Up @@ -175,7 +171,8 @@ impl Thread {
exinf: inner_ptr as abi::EXINF,
// The entry point
task: Some(trampoline),
itskpri: priority,
// Inherit the calling task's base priority
itskpri: abi::TPRI_SELF,
stksz: stack,
// Let the kernel allocate the stack,
stk: crate::ptr::null_mut(),
Expand Down

0 comments on commit 09233ce

Please sign in to comment.