Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How can I limit the number of Cores in multi-process programming

by oiskuu (Hermit)
on Nov 17, 2015 at 17:30 UTC ( [id://1147939]=note: print w/replies, xml ) Need Help??


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.

  • Comment on Re: How can I limit the number of Cores in multi-process programming
  • Download Code

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

    Thanks for the suggestion!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147939]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found