in reply to How can I limit the number of Cores in multi-process programming
Not for the faint of heart, but there is a syscall in perl. To hack a sched_setaffinity call, one might:
#! /usr/bin/perl sub setaffinity { use Config; die if "@Config{qw(ptrsize archname)}" !~ /8.*x86_64.*linux/; my $mask = pack "Q", shift; syscall 203, 0, 8, $mask; } setaffinity 0x22; # allow cores/threads 1 and 5 fork for 1..3; # 8 workers 1 while 1; # busy we are
To easily find out the linux syscall numbers, I recommend looking at strace sources: there are syscallent.h headers for each architecture.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How can I limit the number of Cores in multi-process programming
by milesjin (Initiate) on Nov 19, 2015 at 08:42 UTC |
In Section
Seekers of Perl Wisdom