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.
This commit is contained in:
parent
5ab502c6d3
commit
09233ce3c0
1 changed files with 2 additions and 5 deletions
|
@ -84,10 +84,6 @@ impl Thread {
|
||||||
///
|
///
|
||||||
/// See `thread::Builder::spawn_unchecked` for safety requirements.
|
/// See `thread::Builder::spawn_unchecked` for safety requirements.
|
||||||
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
|
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 {
|
let inner = Box::new(ThreadInner {
|
||||||
start: UnsafeCell::new(ManuallyDrop::new(p)),
|
start: UnsafeCell::new(ManuallyDrop::new(p)),
|
||||||
lifecycle: AtomicUsize::new(LIFECYCLE_INIT),
|
lifecycle: AtomicUsize::new(LIFECYCLE_INIT),
|
||||||
|
@ -175,7 +171,8 @@ impl Thread {
|
||||||
exinf: inner_ptr as abi::EXINF,
|
exinf: inner_ptr as abi::EXINF,
|
||||||
// The entry point
|
// The entry point
|
||||||
task: Some(trampoline),
|
task: Some(trampoline),
|
||||||
itskpri: priority,
|
// Inherit the calling task's base priority
|
||||||
|
itskpri: abi::TPRI_SELF,
|
||||||
stksz: stack,
|
stksz: stack,
|
||||||
// Let the kernel allocate the stack,
|
// Let the kernel allocate the stack,
|
||||||
stk: crate::ptr::null_mut(),
|
stk: crate::ptr::null_mut(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue