Closed biabbas closed 2 weeks ago
The changes enhance support for the VxWorks operating system within the src/unix.rs
and src/lib.rs
modules. Modifications include the introduction of the SCHED_SPORADIC
scheduling policy and updates to error handling functions specific to VxWorks. The RealtimeThreadSchedulePolicy
enum is extended with a new Sporadic
variant, and the set_thread_priority_and_policy
function is adjusted for VxWorks compatibility. Additionally, the src/lib.rs
file includes conditional compilation directives and updates to the ThreadPriorityValue
struct to define a maximum thread priority specific to VxWorks.
File(s) | Change Summary |
---|---|
src/unix.rs | Added Sporadic variant to RealtimeThreadSchedulePolicy . Introduced errno() and set_errno() functions. Updated to_posix method to handle Sporadic . Modified set_thread_priority_and_policy to include VxWorks handling. |
src/lib.rs | Updated module declaration for unix to include target_os = "vxworks" . Defined new MAX constant in ThreadPriorityValue struct for VxWorks. Updated error messages for ThreadPriorityValue to specify range for VxWorks. |
tests/unix.rs | Added support for VxWorks in multiple test functions. Duplicated get_and_set_priority_with_normal_policies for VxWorks. Maintained error handling logic for invalid priority values. |
In the land of threads where bunnies play,
VxWorks hops in, brightening the day.
With policies new and errors in check,
Our library's strong, what the heck!
So let’s thread our way through the code,
With joy in our hearts, let the changes explode! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
r? @iddm
Cargo test fails for VxWorks. The max value check in lib.rs for threadpriority seems to be the problem.
[vxWorks *]# ./unix-2dd6dee514656752.vxe
running 2 tests
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo ... FAILED
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin ... FAILED
failures:
---- get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo stdout ----
thread 'get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo' panicked at 'called `Result::unwrap()` on an `Err` value: "The value is not in the range of [0;99]"', tests/unix.rs:158:82
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin stdout ----
thread 'get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin' panicked at 'called `Result::unwrap()` on an `Err` value: "The value is not in the range of [0;99]"', tests/unix.rs:158:82
failures:
get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo
get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.70s
Test results for VxWorks
[vxWorks *]# ./tests/common-a84adfa34cf086c5.vxe
running 3 tests
test should_be_impossible_to_get_other_thread_native_id_via_threadext ... ok
test should_be_possible_to_get_current_thread_native_id_via_threadext ... ok
test should_be_possible_to_reset_the_same_priority ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s
[vxWorks *]# ./tests/unix-2dd6dee514656752.vxe
running 6 tests
test get_and_set_priority_with_normal_policies::policy_1_ThreadSchedulePolicy__Normal_NormalThreadSchedulePolicy__Other_::priority_1_ThreadPriority__Min ... ok
test get_and_set_priority_with_normal_policies::policy_1_ThreadSchedulePolicy__Normal_NormalThreadSchedulePolicy__Other_::priority_2_ThreadPriority__Max ... ok
test get_and_set_priority_with_normal_policies::policy_1_ThreadSchedulePolicy__Normal_NormalThreadSchedulePolicy__Other_::priority_3_ThreadPriority__Crossplatform_23u8_try_into___unwrap___ ... ok
test get_and_set_priority_with_normal_policy ... ok
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_1_fifo ... ok
test get_and_set_priority_with_realtime_policy_requires_capabilities::case_2_roundrobin ... ok
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.10s
[vxWorks *]# ./tests/thread_priority-16d21276c67c2411.vxe
running 2 tests
test unix::tests::change_between_realtime_and_normal_policies_requires_capabilities ... ok
test unix::tests::thread_schedule_policy_param_test ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s
review? @iddm
@iddm How do we get these changes into a stable release?
Thank you! Available in https://crates.io/crates/thread-priority/1.2.0
Fixes #44