assiging thread to CPu in Multicore env

SIr,

As per the multicore manual i have followed the procedure and i am able to see program on the assigned CPU.
But in multithreaded program what API should i use to assign particular CPU to a given thread.As there are API in linux to do this assignment,i did not found any API in QNX.

How to run multiple different thread on the assigned CPU…please provide me a solution to my problem.

Regards,
Amit

From within each created thread, you can call ThreadCtl( NTO_TCTL_RUNMASK, runmask ) … see also NTO_TCTL_RUNMASK_GET_AND_SET_INHERIT.

If you don’t want to put code in your programs that do this, take a look at the -C option to the “on” command.

Sir,

Thanks for the reply.In the multithread program in each thread i am assigning the cpu to thread,program got complied.But i have one query how to check the CPU assigned to the each thread in the running program.

I tried using PID,ps command but i am not able to see the CPU assigned to the thread.

Regards,
Amit

If you want to see the runmask, use pidin with the -f option. ‘i’ shows you the run mask.

I don’t know of any way to see which processor a thread is instantaneously running on.
I don’t know why that would matter.
The runmask tells you which processor the thread is allowed to run on.
If the runmask has just one bit set, you know.
If the runmask has more than one bit set, you know what the thread is restricted to.
If you need to know more, then you are not doing something right.

pidin -f abNl (last is letter ‘l’)

The fourth column will be core the thread last ran on.

Sir,
Thanks for the reply i am able to see the runmask as well as the last used cpu by process.

just a douth, I just wanted to know that how do we get to know that efficiency ,processing for that particular code have increased,if we are not using momentic but running the code using qcc in the neutrino environment.

Regards,
Amit

In all of my own experimenta I’ve never been able to get any measurable increase in performance by playing with cpu affinity. In the end letting the kernel do its think seems best. I had hope that using cpu affinity would help prevent cache trashing (given the way the cache is setup on Intel processor), but I could never get better performance then the kernel event though there seems to be more thread migrations.