Skip to content

kmc-solid: Inherit the calling task's base priority in Thread::new #93494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
kawadakk committed Jan 31, 2022
commit 09233ce3c0fbcf83abedd7525faa324a2fa2c21c
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