how to bind a process to a CPU

Hi all

please can any body please suggest me how to bind a process to a particular
CPU on unix machine.

i have a unix machine with 2 CPUs and i wanna have my process running on
CPU 0.

please suggest.

if you are using solaris, you can read up on resource management to do that

If you're on aix look for bindprocessor man pages

Hi
thanks for the reply

i am on sunos see the o/p of uname

SunOS gnm029 5.8 Generic_117000-05 sun4u sparc SUNW,Sun-Fire-V440

in solaris:

pbind -> for binding processes to one CPU

psrset -> creation and management of processor sets

i think you are looking for pbind (since you "only" have 2 CPUs).

get you process ids and use the following (bad example here, cause i have only one in my testmashine, but it still work :smiley: ):

root@jumpy # psrinfo
0       on-line   since 01/27/2006 18:44:04
root@jumpy # pgrep cron
196
root@jumpy # pbind -b 0 196
process id 196: was not bound, now 0
root@jumpy # pbind -q
process id 196: 0
root@jumpy # pbind -u 196
process id 196: was 0, now not bound
root@jumpy #

greetings PRESSY

that was wonderful pressy thanq

that is cool, pressy.
When do you use pbind & when do you use resource manager?

well, pbind is a traditional unix/solaris tool which is, on my opinion, one of the basic tools which should come with an OS....

the resource management is a control layer which comes from sun. in solaris 8 you had to pay for it, since solaris9 it is included. the basic idea of resource management is allocate computing resources, such as processor time, monitor how the allocations are being used, then adjust the allocations as necessary, restrict access to a specific resource, offer resources to workloads on a preferential basis or isolate workloads from each another.... you could deny resources or prefer one application over another for a larger set of allocations than otherwise permitted or prevent an application from consuming resources indiscriminately.

a very nice implementation was done in solaris 10 and the solaris-containers. you can bind these virtual OS instances to processor sets and to a preconfigured value of memory. zone1 only works on CPU0 and CPU1 with 2G RAM, zone2 zone3 and zone4 have to share CPU2 - CPU7 and the rest of memory. one thing my costumers really like is the "fair scheduling" rule. e.g: every zone could have as much resources as my machine is able provide but if zone1 needs more power, the other instances "have to give" the resources back, controlled by the kernel, preconfigured by rule-sets, no interaction needed..... anyhow, you are able to change this allocation live. this could be very important e.g if one process hangs and eat up the whole CPUs or memory, no problem with RM....

just try it, it works great. i found a very nice tutorial with zones and resource management for solaris 10 from Brendan Gregg...

regards PRESSY

tks for the reply. I am familiar with resource manager, 1st time encounter with pbind .

Hello pressy,

read your post, pretty intersting. I tried accessing the manual "zones and resource management" but had no luck. Is there another?

Thank you

Certainly there is :). On topic, for Linux you may use "schedutils" for binding process to a given processor.

oh, that's a pity... that's one reason why i took a backup :wink:
and guess what! i found it in my 10gig docu collection :smiley:
perhabs i will find some time and rewrite it for my wiki... old but still a good work...
see the attachment...

regards

  • PRESSY