MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / sched_getaffinity

Function sched_getaffinity

src/backend/linux_raw/thread/syscalls.rs:480–497  ·  view source on GitHub ↗
(pid: Option<Pid>, cpuset: &mut RawCpuSet)

Source from the content-addressed store, hash-verified

478
479#[inline]
480pub(crate) fn sched_getaffinity(pid: Option<Pid>, cpuset: &mut RawCpuSet) -> io::Result<()> {
481 unsafe {
482 // The raw Linux syscall returns the size (in bytes) of the `cpumask_t`
483 // data type that is used internally by the kernel to represent the CPU
484 // set bit mask.
485 let size = ret_usize(syscall!(
486 __NR_sched_getaffinity,
487 c_int(Pid::as_raw(pid)),
488 size_of::<RawCpuSet, _>(),
489 by_mut(&mut cpuset.bits)
490 ))?;
491 let bytes = as_mut_ptr(cpuset).cast::<u8>();
492 let rest = bytes.wrapping_add(size);
493 // Zero every byte in the cpuset not set by the kernel.
494 rest.write_bytes(0, core::mem::size_of::<RawCpuSet>() - size);
495 Ok(())
496 }
497}
498
499#[inline]
500pub(crate) fn sched_setaffinity(pid: Option<Pid>, cpuset: &RawCpuSet) -> io::Result<()> {

Callers

nothing calls this directly

Calls 2

as_mut_ptrFunction · 0.85
ret_usizeFunction · 0.50

Tested by

no test coverage detected