Linux::CPUAffinity - set and get a process's CPU affinity mask
use Linux::CPUAffinity; # get affinity of this process my $cpus = Linux::CPUAffinity->get(0); # eg: [0, 1, 2, 3] # other process my $cpus = Linux::CPUAffinity->get($pid); # set affinity of this process Linux::CPUAffinity->set(0 => [0,1]); # other process Linux::CPUAffinity->set($pid => [0]); # utility method to get processors my $num = Linux::CPUAffinity->num_processors();
Linux::CPUAffinity is a wrapper module for Linux system call sched_getaffinity(2) and sched_setaffinity(2).
This module is only available on GNU/Linux.
Get the CPU affinity mask of the process.
Set the CPU affinity mask of the process.
Get the number of processors currently online (available).
Copyright (C) Jiro Nishiguchi.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Jiro Nishiguchi <jiro@cpan.org>
Sys::CpuAffinity
To install Linux::CPUAffinity, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::CPUAffinity
CPAN shell
perl -MCPAN -e shell install Linux::CPUAffinity
For more information on module installation, please visit the detailed CPAN module installation guide.