* looking for a function
@ 2008-09-16 13:26 Xu Yang
2008-09-16 14:03 ` Steve Graegert
[not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Xu Yang @ 2008-09-16 13:26 UTC (permalink / raw)
To: linux-c-programming
Hi guys,
I am looking for a function that can show me the current thread is
running on which cpu.
e.g I am using pthread to write a multithreaded program, in each
thread I would like to insert such kind of function so that I can know
on which cpu this thread is running on.
which function should be used?
thanks for the help!!
best regards,
Yang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: looking for a function
2008-09-16 13:26 looking for a function Xu Yang
@ 2008-09-16 14:03 ` Steve Graegert
[not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Steve Graegert @ 2008-09-16 14:03 UTC (permalink / raw)
To: Xu Yang; +Cc: linux-c-programming
Xu Yang,
On Linux sched_getcpu(3) comes to mind. This function is not
particularly useful since the information returned by the function
might not be correct at the point of its return as threads can be
switched to other CPUs (read: cores) at anytime (although CPU/core
switching can be quite expensive due to cache line bouncing for
instance)
So, once the information has been obtained it might already be
obsolete. Anyway, I hope that is what you're looking for.
\Steve
--
Steve Grägert
On Tue, Sep 16, 2008 at 3:26 PM, Xu Yang <risingsunxy@googlemail.com> wrote:
>
> Hi guys,
>
> I am looking for a function that can show me the current thread is
> running on which cpu.
>
> e.g I am using pthread to write a multithreaded program, in each
> thread I would like to insert such kind of function so that I can know
> on which cpu this thread is running on.
>
> which function should be used?
>
> thanks for the help!!
>
> best regards,
>
>
>
> Yang
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: looking for a function
[not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
@ 2008-09-16 14:14 ` Xu Yang
0 siblings, 0 replies; 3+ messages in thread
From: Xu Yang @ 2008-09-16 14:14 UTC (permalink / raw)
To: Steve Graegert; +Cc: linux-c-programming
Hi Steve,
thanks for your reply :-)
I will try this. I am evaluating some scheduling algorithm, so I would
like to learn about how the threads migrate. That is why I am asking
for such kind of function.
thank for your help!
Bes regards,
Yang
2008/9/16, Steve Graegert <graegerts@gmail.com>:
> Xu Yang,
>
> On Linux sched_getcpu(3) comes to mind. This function is not particularly
> useful since the information returned by the function might not be correct
> at the point of its return as threads can be switched to other CPUs (read:
> cores) at anytime (although CPU/core switching can be quite expensive due to
> cache line bouncing for instance)
>
> So, once the information has been obtained it might already be obsolete.
> Anyway, I hope that is what you're looking for.
>
> \Steve
>
> --
>
> Steve Grägert
>
>
>
> On Tue, Sep 16, 2008 at 3:26 PM, Xu Yang <risingsunxy@googlemail.com> wrote:
> >
> > Hi guys,
> >
> > I am looking for a function that can show me the current thread is
> > running on which cpu.
> >
> > e.g I am using pthread to write a multithreaded program, in each
> > thread I would like to insert such kind of function so that I can know
> > on which cpu this thread is running on.
> >
> > which function should be used?
> >
> > thanks for the help!!
> >
> > best regards,
> >
> >
> >
> > Yang
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> >
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-16 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-16 13:26 looking for a function Xu Yang
2008-09-16 14:03 ` Steve Graegert
[not found] ` <6a00c8d50809160701v2cf11b93ta86c30398cfe2e6b@mail.gmail.com>
2008-09-16 14:14 ` Xu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).