Skip to content

Commit 09233ce

Browse files
committed
kmc-solid: Inherit the calling task's base priority in Thread::new
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.
1 parent 5ab502c commit 09233ce

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

library/std/src/sys/itron/thread.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ impl Thread {
8484
///
8585
/// See `thread::Builder::spawn_unchecked` for safety requirements.
8686
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
87-
// Inherit the current task's priority
88-
let current_task = task::try_current_task_id().map_err(|e| e.as_io_error())?;
89-
let priority = task::try_task_priority(current_task).map_err(|e| e.as_io_error())?;
90-
9187
let inner = Box::new(ThreadInner {
9288
start: UnsafeCell::new(ManuallyDrop::new(p)),
9389
lifecycle: AtomicUsize::new(LIFECYCLE_INIT),
@@ -175,7 +171,8 @@ impl Thread {
175171
exinf: inner_ptr as abi::EXINF,
176172
// The entry point
177173
task: Some(trampoline),
178-
itskpri: priority,
174+
// Inherit the calling task's base priority
175+
itskpri: abi::TPRI_SELF,
179176
stksz: stack,
180177
// Let the kernel allocate the stack,
181178
stk: crate::ptr::null_mut(),

0 commit comments

Comments
 (0)