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?
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.
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.
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.