Skip to content

Commit 4757a93

Browse files
authored
Rollup merge of #93494 - solid-rs:fix-kmc-solid-spawned-task-priority, r=Mark-Simulacrum
kmc-solid: Inherit the calling task's base priority in `Thread::new` This PR fixes the initial priority calculation of spawned threads on the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. Fixes a spawned task (an RTOS object on top of which threads are implemented for this target; unrelated to async tasks) getting an unexpectedly higher priority if it's spawned by a task whose priority is temporarily boosted by a priority-protection mutex.
2 parents 24737bd + 09233ce commit 4757a93

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)