Task threading question

Mackay, Michael yellowdog-general@lists.terrasoftsolutions.com
Fri Feb 6 15:36:01 2004


Duke,

Thanks for your reply.  It fills in a lot of questions, and I think that =
I'm getting my task's threads scheduled in both CPUs after all.  Top =
just looks different in intel vs PPC.  On Intel I see many copies of my =
task, each representing (I assume) a thread of the task.  On YDL, I just =
see one process, and it's at 99.9%.  But if I go and look at each =
individual CPU, the total free CPU does not add up to the other CPU =
being free.  So I'm using both, it just isn't presented clearly in =
top...

Maybe there's a better CPU utilization tool that shows this....

Anyway, I think my question has been answered...thanks!

Mike

-----Original Message-----
From: Duke Robillard [mailto:duke@io.com]
Sent: Friday, February 06, 2004 3:44 PM
To: yellowdog-general@lists.terrasoftsolutions.com
Subject: Re: Task threading question



 > I have a general question about YDL and Linux compared to the Intel =
port
 > concerning threads.  I know that in some versions of Unix, the task =
is
 > the smallest schedulable quantity and as such can only run in one CPU =
at
 > a time.  If the task is running threads, they still stay with the =
task -

Linux is kind of weird about threads.  In Linux, the distinction
between "thread" and "process" is kind of blurred.  They are
both "Kernel-Schedulable-Entities" ("KSEs") created by the
clone() system call.  Both fork() and pthread_create() are
user-space wrappers around clone().   It used to be that when
you called clone(), you got a new ProcessID, even if what you
really wanted was a thread.  This created lots of confusion
amoung UNIX-threads programmers when they went to Linux, and
they saw all these processes created by their multi-threaded
code.  In the new kernel (2.6, and backported by RedHat to
their 2.4.something), support was added to fix that, but threads
and processes are both still KSEs created by clone().

So, this is all good news to you; it means everytime you call
pthread_create(), you get a new kernel scheduleable entity.
If you've got an Linux kernel compiled with the SMP option,
your threads will be schedule on all the CPUs in your system.

 >My question is this - assuming YDL 3.0 or higher, is there a kernel
 >compile option, or an application compile option, or some =
configuration

I suspect you'll need to re-compile the kernel to turn on SMP
support, but you don't have to do anything special about your
threaded application code to get it to use the CPUs.

There are a bunch of gotchas about threads on Linux, though.
You may want to check out these:

http://homepages.tesco.net./%7EJ.deBoynePollard/FGA/linux-thread-problems=
.html
http://pauillac.inria.fr/~xleroy/linuxthreads/

Duke


_______________________________________________
yellowdog-general mailing list
yellowdog-general@lists.terrasoftsolutions.com
http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-general