Mladen Nikitovic wrote:
> Hi again,
>
> A followup on pbind...
>
> I have a question regarding binding a thread to a processor. I'm using the 
> function processor_bind within an application, but I'm unsure which 
> parameters I should use.
>
> This is my current approach
>  int result = processor_bind(P_LWPID, P_MYID, processor_id, NULL);
>
> However, I don't think P_MYID will return the thread_id, right? 
>   
This will bind the current lwp/thread to "processor_id". It's convenient 
to use P_MYID, because you don't need to dig around for the current 
thread's lwpid, the implementation will do that for you.

> I could use pthread_self() just after I created a thred - it returns 
> pthread_t (which is also an integer as well as id_t, the second parameter 
> type of processor_bind). Is that a possible (and correct) way to bind a 
> thread to a processor?
>   
You can issue the processor_bind(2) call and use P_MYID rather than 
using pthread_self() to find the id.

> Secondly, the application takes the number of threads, N, as a parameter, but 
> spawns only N-1 threads because the main process does part of the work. I'm 
> unsure how to acquire a correct thread id of the main processs to bind it to 
> a processor. Do you have any idea on how to do this? I don't think using 
> pthread_self before creating the other threads would do the trick....
>   
I think you can use P_MYID for the main thread just like you can from 
any newly created threads.

Thanks,
-Eric
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to