Operating System - HP-UX
1836752 Members
2586 Online
110109 Solutions
New Discussion

How to Assign a Process to a Specific Processor

 
SOLVED
Go to solution
Tom Jackson
Valued Contributor

How to Assign a Process to a Specific Processor

Hi:

Can someone tell me if its possible to assign a process to a specific processor on a multi processor system?

I'm running HP-UX 11.0 on an N Class server.

Thanks,

Tom
11 REPLIES 11
Robert-Jan Goossens
Honored Contributor
Solution

Re: How to Assign a Process to a Specific Processor

Hi Tom,

I think you will need something like PRM (process resource manager), take a look at next link.

http://www.software.hp.com/portal/swdepot/displayProductInfo.do?productNumber=B3835DATRY

Hope this helps,
Robert-Jan
Ravi_8
Honored Contributor

Re: How to Assign a Process to a Specific Processor

Hi Tom

this is for 10.2

http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000024603782

i am not sure about 11.0
never give up
Dan Herington
Advisor

Re: How to Assign a Process to a Specific Processor

Hi Tom,

HP-UX 11i supports PSETs, which would do what you want. You can use PRM to set it up or you could use the psrset command.

Dan
Chris Watkins_1
Respected Contributor

Re: How to Assign a Process to a Specific Processor

We actually use pbind... but I can't for the life of me
remember from whence it came. I've attached a gzipped binary.
(In case you'd like to give it a try)

I looked for the source, depot, or package, to no avail.
(I will find this... and post again later)

We've simply copied around as needed. Works just fine.



Usage is simple.
To bind:
pbind -b PROCID PID

To query:
pbind -q PID

To UNbind:
pbind -u PID



Not without 2 backups and an Ignite image!
A. Clay Stephenson
Acclaimed Contributor

Re: How to Assign a Process to a Specific Processor

Actually, if you know a little C this is rather easy. The mpctl() system call will do this either for the calling process or another process if the user has permissions. Man mpctl for details.
If it ain't broke, I can fix that.
Chris Watkins_1
Respected Contributor

Re: How to Assign a Process to a Specific Processor

C is definitely a skill I want to acquire.
(Beyond simple "hello world" and "system" calls, that is)

I did a truss on the pbind command we use, and it does
indeed simply call mpctl functions to do its dirty work.
Thanks.

(And no points here, please)
Not without 2 backups and an Ignite image!
James A. Donovan
Honored Contributor

Re: How to Assign a Process to a Specific Processor

If you can read Chinese (or even if you cant), there is an example at the following link of using the mpctl function to create a small progrma which works like pbind.

http://www.cbronline.com/currentnews/84088db57bc626a780256e35003855e6
Remember, wherever you go, there you are...
James A. Donovan
Honored Contributor

Re: How to Assign a Process to a Specific Processor

If you can read Chinese (or even if you cant), there is an example at the following link of using the mpctl function to create a small progrma which works like pbind.

http://www.hp.com.tw/ssn/unix/0208/unix020803.asp
Remember, wherever you go, there you are...
Tom Jackson
Valued Contributor

Re: How to Assign a Process to a Specific Processor

Hi:

Thanks for your responses. I've been tooling with the mpctl call and I'm a little confused. I call it to assign a PID to an SPU and it returns the SPU number that I am passing, but when I inspect the process it's not where I think it should be. My process started on processor 1 and ended on 0. Why didn't it move to processor 4? Here's my simple minded code:

#include
#include
#include
#include
#include
main( argc, argv, envp )
int argc;
char *argv[];
char *envp[];
{
int retVal;
printf("%u\n",getpid());
system("ps -ef|grep zzdx8n > t1.out");
retVal=mpctl(MPC_GETNUMSPUS);
printf("%u\n",retVal);
retVal=mpctl(MPC_GETCURRENTSPU);
printf("%u\n",retVal);
retVal=mpctl(MPC_SETPROCESS_FORCE,4,getpid());
printf("%u\n",retVal);
sleep(1);
retVal=mpctl(MPC_GETCURRENTSPU);
printf("%u\n",retVal);
system("ps -ef|grep zzdx8n >> t1.out");
retVal=mpctl(MPC_GETCURRENTSPU);
printf("%u\n",retVal);


Here's the output file:

zzdx8n 2492 25134 1 08:45:01 ttyp3 0:00 ./t1
zzdx8n 2493 2492 1 08:45:01 ttyp3 0:00 sh -c ps -ef|grep zzdx8n > t1.out
zzdx8n 2494 2493 5 08:45:01 ttyp3 0:00 ps -ef
zzdx8n 2492 25134 0 08:45:01 ttyp3 0:00 ./t1
zzdx8n 2496 2492 1 08:45:02 ttyp3 0:00 sh -c ps -ef|grep zzdx8n >> t1.out
zzdx8n 2498 2496 0 08:45:02 ttyp3 0:00 grep zzdx8n
zzdx8n 2497 2496 2 08:45:02 ttyp3 0:00 ps -ef
A. Clay Stephenson
Acclaimed Contributor

Re: How to Assign a Process to a Specific Processor

Well, TOM the first thing that I notice is your assumption that the processor id's go in 0,1,2,3, ... order.

Your really have to do
a
first_id = mpctl(MPC_GETFIRSTSPU_SYS,(spu_t) 0,(pid_t) 0);
you then enter a loop using
curr_id = next_id = first_id
while (next_id >= 0)
{
next_id = mpctl(MPC_GETNEXTSPU_SYS,(spu_t) curr_id,(pid_t) 0);
if (next_id >= 0)
{
curr_id = next_id;
}
}

You really have to build up an array (or list) of vaslid id's rather than blindly sending in 4.
If it ain't broke, I can fix that.
Tom Jackson
Valued Contributor

Re: How to Assign a Process to a Specific Processor

Hi Clay:

Thanks for your response. I'm not sure listing the SPU numbers helped, however, I'm convinced that the call is working properly. My SPUs are numbered 0-7, and the MCP_SETPROCESS_FORCE command is moving the process to another processor. The ps command may not have been showing the correct SPU number. When I used the top command, it showed the SPU that I expected. I also did a couple MCP_SETPROCESS_FORCE commands and saw the process move with the top command.

I had to remove the "_SYS" from your request argument to get it to compile.

Thanks again!

TOM