about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-31 07:00:47 +0100
committerGitHub <noreply@github.com>2022-01-31 07:00:47 +0100
commit4757a931cd69f57ab3e1d823ffa44b18c37e1223 (patch)
treea4c00cca430aac6bb465c6ea43c11a123f86d98a
parent24737bd1abaf5955905cc153ec8ec4bdef074d3f (diff)
parent09233ce3c0fbcf83abedd7525faa324a2fa2c21c (diff)
downloadrust-4757a931cd69f57ab3e1d823ffa44b18c37e1223.tar.gz
rust-4757a931cd69f57ab3e1d823ffa44b18c37e1223.zip
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.
-rw-r--r--library/std/src/sys/itron/thread.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/library/std/src/sys/itron/thread.rs b/library/std/src/sys/itron/thread.rs
index ebcc9ab26e0..a8ecc1ada4a 100644
--- a/library/std/src/sys/itron/thread.rs
+++ b/library/std/src/sys/itron/thread.rs
@@ -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),
@@ -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(),