Oracle Blog

Improving application-driven technology

Processor bindings in Solaris - quick and dirty

A note I had written to...someone...very...close... and - thought would be worthwhile to convert to a blog
Ok, so I remembered our conversation from last week about binding processors to CPUs and seeing which processors
these processes are actually bound to.

I wanted to refresh this in my memory and went through this last night and here are my notes.

I am doing this on a Solaris 10 server with 2 CPUs, but am assuming that this should work on Solaris 8 as well.
The only caution I have is around not being completely sure whether the 'ps' command was actually enhanced to take '-o psr' as one of the 'format' arguments
to it back in Solaris 8 or not. (You can validate this just by running '/usr/bin/ps -o' alone on the command line and looking for a
line that includes 'psr' and/or 'pset' in the output.

So now I have a process bound to a CPU, so this should be somewhat equal given
your original question of 'how can I see what CPU a process is bound to?'.
Armed with a PID of a process of interest, I feed it to 'ps' and ask 'ps' to shape
its output format to include the actual processor, and I get my answer below:

root@ultra2cd:/export/home/isaac: 23:31 > ps -p 16029 -o psr
PSR
0

Looking at the various additional formats that 'ps' is capable of arranging, I can include
things like the pid itself, or the fname, or even the memory address of the process (see
'/usr/bin/ps -o' for the additional types of formats supported).

One last comment: notice how the 'sh' process has a '-' hyphen in the PSR column.
That is because the 'sh' process is a parent of 'tcsh' and, since I only bound 'tcsh' itself,
only tcsh's children will be bound, not the parents. Processor bindings are inherited from the parent.

About

Isaac Rozenfeld has been a Principal Product Manager for Oracle Solaris; responsibilities have included bettering the portfolio of networking and installation technologies - all with a focus on easing application deployments