Open MPI logo

PLPA Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all PLPA Users mailing list

Subject: Re: [PLPA users] sched_getaffinity and sched_setaffinity
From: Srinivas G. (srinivasg_at_[hidden])
Date: 2009-03-05 10:35:35


> On Mar 5, 2009, at 8:46 AM, Srinivas G. wrote:
>
> > Please let me know whether the plpa_sched_getaffinity and
> > plpa_sched_setaffinity are equivalent to the Windows
> > GetProcessAffinityMask and SetThreadAffinityMask /
> > SetProcessAffinityMask API.
>

Dear All,

I found that these sched_setaffinity and sched_getaffinity are almost
equivalent to the Windows SetProcessAffinityMask and
GetProcessAffinityMask. However, I did not understand the
SetThreadAffinityMask equivalent API. I guess, I shall need to use the
sched_setaffinity API with thread id is the 1st argument. But, the
argument to the sched_setaffinity is pid_t where as thread id is
pthread_t type. My question is, shall I type cast the pthread_t to pid_t
type like

sched_setaffinity((pid_t)pthreadid, sizeof(cpu_set_t), &mask)

Please let me know, how can I pass the pthread_t (thread id) type to a
sched_setaffinity API which takes as pid_t. There is a API gettid()
which returns the thread id of the current process. My requirement is a
bit different that from one thread I will set the affinity of the
another thread. So, I need to pass the thread id of a different process
not the current process.

Please suggest me.

Thanks and Regards,
Srinivas G