Skip to content

Commit

Permalink
bring back else code in set_thread_priority_and_policy
Browse files Browse the repository at this point in the history
  • Loading branch information
biabbas committed Oct 14, 2024
1 parent c252faa commit b76e900
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,29 @@ pub fn set_thread_priority_and_policy(
e => Err(Error::OS(e)),
}
} else {
panic!("unsupported in vxworks");
// Normal priority threads must be set with static priority 0.
let params = ScheduleParams { sched_priority: 0 }.into_posix();

let ret = unsafe {
libc::pthread_setschedparam(
native,
policy.to_posix(),
&params as *const libc::sched_param,
)
};

if ret != 0 {
return Err(Error::OS(ret));
}

// Normal priority threads adjust relative priority through niceness.
set_errno(0);
let ret = unsafe { libc::setpriority(libc::PRIO_PROCESS, 0, fixed_priority) };
if ret != 0 {
return Err(Error::OS(errno()));
}

Ok(())
}
}
}
Expand Down Expand Up @@ -827,7 +849,7 @@ impl TryFrom<u8> for ThreadPriority {

#[cfg(test)]
mod tests {
use crate::unix::*;
use crate::vxworks::*;

#[test]
fn thread_schedule_policy_param_test() {
Expand Down

0 comments on commit b76e900

Please sign in to comment.