Task threading question

Duke Robillard yellowdog-general@lists.terrasoftsolutions.com
Fri Feb 6 13:43:01 2004


 > 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