[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1102041326330.4611@router.home>
Date: Fri, 4 Feb 2011 13:29:25 -0600 (CST)
From: Christoph Lameter <cl@...ux.com>
To: Sri Ram Vemulpali <sri.ram.gmu06@...il.com>
cc: Kernel-newbies <kernelnewbies@...linux.org>,
linux-kernel-mail <linux-kernel@...r.kernel.org>
Subject: Re: Thread Affinity structure
On Fri, 4 Feb 2011, Sri Ram Vemulpali wrote:
> I have doubt regarding how the thread affinity (to processor) is
> defined in a process (task). If there is only single thread in a
> process, then when process calls itself on binding to a core, will let
> run on that core forever. But, what if there are multiple threads, in
> a process (task). If the main thread calls set affinity to a core, is
> it going to get inherited to all other threads, or just the calling
> thread in a task. What happens when forked a process with threads that
> has affinity to a core. Please can anyone point me to the literature
> on this. Thanks in advance.
See "man sched_setaffinity"
"
The affinity mask is actually a per-thread attribute that can be
adjusted independently for each of the threads in a thread group. The
value returned from a call to gettid(2) can be passed in the argument
pid. Specifying pid as 0 will set the attribute for the calling thread,
and passing the value returned from a call to getpid(2) will set the
attribute for the main thread of the thread group. (If you are using
the POSIX threads API, then use pthread_setaffinity_np(3) instead of
sched_setaffinity().)
"
The setting of the affinity occurs for the running thread if pid == 0.
Affinity masks are inherited across forks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists