diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sched.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sched.rs b/src/sched.rs index 943ed6ec..aa2b90b4 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -290,6 +290,13 @@ mod sched_affinity { Errno::result(res).and(Ok(cpuset)) } + + /// Determines the CPU on which the calling thread is running. + pub fn sched_getcpu() -> Result<usize> { + let res = unsafe { libc::sched_getcpu() }; + + Errno::result(res).map(|int| int as usize) + } } /// Explicitly yield the processor to other threads. |