Re: [arm-gnu] How to check the core execution for each thread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] How to check the core execution for each thread?
- To: Charly Bechara <charly.bechara@xxxxxxx>
- Subject: Re: [arm-gnu] How to check the core execution for each thread?
- From: Carlos O'Donell <carlos@xxxxxxxxxxxxxxxx>
- Date: Tue, 22 Apr 2008 10:13:40 -0400
Charly Bechara wrote:
I have a multithreaded C program executing on an MPCore system. I want
to know if there is any function from glibc or a kernel system call
which can return me the current core where the thread is executing on?
There is no such function call. Even if there was, by the time the
answer returns to userspace the thread may have been migrated to another
core.
If you want a thread to run on a specific core you will need to look
into the CPU affinity functions (sched_set/getaffinity). The affinity
functions allow you to control which CPU may run the thread (or
process). Be aware that this interface has changed at least 3 times, and
requires coordinated glibc and kernel support. I recommend the interface
which uses cpu_set_t.
Good luck!
Cheers,
Carlos.
--
Carlos O'Donell
CodeSourcery
carlos@xxxxxxxxxxxxxxxx
(650) 331-3385 x716