Skip to content

Commit c25d657

Browse files
committed
Auto merge of rust-lang#611 - vityafx:add-pthread-priority-functions, r=alexcrichton
Add schedule params & priority pthread functions Fixes rust-lang#609. Provides bindings to `pthread_getschedparam`, `pthread_setschedparam` and `pthread_setschedprio` functions. P.S. My first PR in such a project. P.P.S. `libc-test` crashed at building stage with a lot of errors, so I hope `travis` will do a check. P.P.P.S. These functions are tested to work on Linux (Ubuntu 14.04) with my own crate. I will release it next week, it provides ability to control thread schedule policies and priorities.
2 parents 539e50c + fbec8eb commit c25d657

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/unix/notbsd/linux/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,8 @@ extern {
927927
serv: *mut ::c_char,
928928
sevlen: ::socklen_t,
929929
flags: ::c_int) -> ::c_int;
930+
pub fn pthread_setschedprio(native: ::pthread_t,
931+
priority: ::c_int) -> ::c_int;
930932
pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
931933
old_limit: *mut ::rlimit) -> ::c_int;
932934
pub fn prlimit64(pid: ::pid_t,

src/unix/notbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,12 @@ extern {
963963
pshared: ::c_int) -> ::c_int;
964964
pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t,
965965
pshared: *mut ::c_int) -> ::c_int;
966+
pub fn pthread_getschedparam(native: ::pthread_t,
967+
policy: *mut ::c_int,
968+
param: *mut ::sched_param) -> ::c_int;
969+
pub fn pthread_setschedparam(native: ::pthread_t,
970+
policy: ::c_int,
971+
param: *const ::sched_param) -> ::c_int;
966972
pub fn sched_getaffinity(pid: ::pid_t,
967973
cpusetsize: ::size_t,
968974
cpuset: *mut cpu_set_t) -> ::c_int;

0 commit comments

Comments
 (0)