* [Xenomai-help] Thread scheduling on mult-processor systems
@ 2008-06-16 1:33 Rob Gubler
2008-06-16 9:40 ` Philippe Gerum
0 siblings, 1 reply; 2+ messages in thread
From: Rob Gubler @ 2008-06-16 1:33 UTC (permalink / raw)
To: xenomai
[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]
Hello,
I am trying execute 2 threads on 2 separate processors. To do this I
created 2 threads, each using the FIFO scheduler where both threads have the
same priority defined by sched_get_priority_max(SCHED_FIFO). Each thread is
initialized to run on a specific CPU with a call to
pthread_setaffinity_np(...); Thread 1 on CPU 0, and Thread 2 on CPU 1. I
verified each thread was assigned correctly by calling
pthread_getaffinity_np(...), and also by looking at /proc/xenomai/sched,
while the program was running.
For the purposes of testing, both threads do the same thing:
for(unsigned long i = 0; i != 9000000; i++)
{
if(!(i % 50000))
{
std::cout << "tick" << std::endl;
}
sched_yield();
}
std::cout << "elapsed time: " << [elapsed time];
My hope was that when these threads would execute simultaneously, they would
truly run in parallel on their respective processor. But, what I am
noticing is the elapsed time when both threads run is 12 seconds, while when
only one thread runs is 6 seconds. So, I haven't seem to have bought any
performance improvements by assigning the thread to run on a specific
processor.
Where have I gone wrong in my line of thinking?
-Rob
[-- Attachment #2: Type: text/html, Size: 2027 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai-help] Thread scheduling on mult-processor systems
2008-06-16 1:33 [Xenomai-help] Thread scheduling on mult-processor systems Rob Gubler
@ 2008-06-16 9:40 ` Philippe Gerum
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2008-06-16 9:40 UTC (permalink / raw)
To: Rob Gubler; +Cc: xenomai
Rob Gubler wrote:
> Hello,
>
> I am trying execute 2 threads on 2 separate processors. To do this I
> created 2 threads, each using the FIFO scheduler where both threads have
> the same priority defined by sched_get_priority_max(SCHED_FIFO). Each
> thread is initialized to run on a specific CPU with a call to
> pthread_setaffinity_np(...); Thread 1 on CPU 0, and Thread 2 on CPU 1.
> I verified each thread was assigned correctly by calling
> pthread_getaffinity_np(...), and also by looking at /proc/xenomai/sched,
> while the program was running.
>
> For the purposes of testing, both threads do the same thing:
>
> for(unsigned long i = 0; i != 9000000; i++)
> {
> if(!(i % 50000))
> {
> std::cout << "tick" << std::endl;
> }
>
> sched_yield();
> }
>
> std::cout << "elapsed time: " << [elapsed time];
>
> My hope was that when these threads would execute simultaneously, they
> would truly run in parallel on their respective processor. But, what I
> am noticing is the elapsed time when both threads run is 12 seconds,
> while when only one thread runs is 6 seconds. So, I haven't seem to
> have bought any performance improvements by assigning the thread to run
> on a specific processor.
>
> Where have I gone wrong in my line of thinking?
>
Most of the code executed in this loop involves serialization, hence the result.
--
Philippe.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-16 9:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-16 1:33 [Xenomai-help] Thread scheduling on mult-processor systems Rob Gubler
2008-06-16 9:40 ` Philippe Gerum
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.