summaryrefslogtreecommitdiff
path: root/src/sched.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sched.rs')
-rw-r--r--src/sched.rs7
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.