Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Are OpenBSD threads (pthreads) using more than one core of multicore CPUs?

126 views
Skip to first unread message

ttsi...@gmail.com

unread,
Apr 30, 2008, 5:44:06 AM4/30/08
to
I recently installed OpenBSD 4.2 on my Core2Duo 4500. Naturally, I
used the bsd.mp kernel, to make use of both cores of my CPU. Indeed, I
found out that if I spawn two CPU-intensive processes, they are
allocated on different cores, and thus make full use of my CPU. Good.

When I tried the same test using pthreads, however, I found out that
both threads were allocated on the same core. It appears that threads
are not "dispersed" amongst different cores, and are thus not getting
any benefit from my dual core CPU.

What am I doing wrong?

Marc Espie

unread,
Apr 30, 2008, 8:17:10 AM4/30/08
to
In article <d4cfbe5e-5c1c-4cad...@e39g2000hsf.googlegroups.com>,

<ttsi...@gmail.com> wrote:
>When I tried the same test using pthreads, however, I found out that
>both threads were allocated on the same core. It appears that threads
>are not "dispersed" amongst different cores, and are thus not getting
>any benefit from my dual core CPU.

That is correct.

>What am I doing wrong?

You don't understand things, that's all.

pthreads is a purely userland threads library, there's no way it can
distribute threads among different processors because the kernel doesn't
even know about those threads.

ttsi...@gmail.com

unread,
Apr 30, 2008, 8:52:02 AM4/30/08
to
Thanks for clearing it up, Marc.

As a side note, however, allow me to point that this sounds like a
severe
limitation for an OS - we are living in the multicore era. Both Linux
and Windows
are able to allocate threads to different cores automatically, where
as apparently
OpenBSD can only do things in parallel if you "fork". A lot of
packages are
using threads...

Just my 2c.

Thanassis.

Marc Espie

unread,
Apr 30, 2008, 10:45:51 AM4/30/08
to
In article <d228f536-768f-47af...@y38g2000hsy.googlegroups.com>,

<ttsi...@gmail.com> wrote:
>Thanks for clearing it up, Marc.
>
>As a side note, however, allow me to point that this sounds like a
>severe
>limitation for an OS - we are living in the multicore era. Both Linux
>and Windows
>are able to allocate threads to different cores automatically, where
>as apparently
>OpenBSD can only do things in parallel if you "fork". A lot of
>packages are
>using threads...

Threaded programming is difficult, and very hard to get right, and fraught
with security issues...

That said, kernel-mode threads are on the todo-list of some people.
They're not ready yet.

0 new messages