From: Philippe Gerum <rpm@xenomai.org>
To: Rob Gubler <rgubler@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Thread scheduling on mult-processor systems
Date: Mon, 16 Jun 2008 11:40:41 +0200 [thread overview]
Message-ID: <48563519.1060300@domain.hid> (raw)
In-Reply-To: <e4ef24880806151833n4e36005coadc1087c29f5b1cb@domain.hid>
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.
prev parent reply other threads:[~2008-06-16 9:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-16 1:33 [Xenomai-help] Thread scheduling on mult-processor systems Rob Gubler
2008-06-16 9:40 ` Philippe Gerum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48563519.1060300@domain.hid \
--to=rpm@xenomai.org \
--cc=rgubler@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.