In article <a242re$gop / ftp.ee.vill.edu>, "Chris Gehlker"
<gehlker / fastq.com> wrote:

> On 1/16/02 1:54 AM, "Markus Jais" <mjais / web.de> wrote:
> 
>> hello
>> 
>> this is more of a general question on Ruby Threads. I have never used
>> threads in any language until now, so I am a complete newbie to this
>> topic. (have read something about threads in a bad java book, but this
>> didn't help me with the following questions)
> 
> I'm a Ruby newbie but I'll take a shot.
>> I read somewhere that Ruby threads are no native threads.
> 
> That's right.
>> what exactly is a native thread?? (something using pthreads on
linux??)

A native thread is a execution path through a process space with shared
memory intra-process, but which takes it own singular execution path.
Basically, it's a piece of the process that can do it's own work, but
doesn't get it's own memory. NATIVE threads are different than PThreads
in that native threads are kernel-schedulable entities, whereas PThreads
are not known to the kernel (i.e. a process using PThreads will appear to
be a single-threaded process to the kernel).

> 
> Yes, pthreads on Unix and the WIN32 threads on Windows.

PThreads are not native threads. PThreads is a package created at MIT to
faciliate portable threading model. Tthey are user-space threads
(switched by the process itself, susceptible to full process-block on
single thread blocking).

>> what is the advantage / disadvantage of the ruby approach to threads??
>> 
>> are native threads faster??
> 
> The Ruby method is portable. I don't think it's as fast and it can't use
> more than one processor at a time.

The disadvantages are that one thread can cause the entire process to
block, and the kernel knows nothing of the threads inside a Ruby process.
Thus it cannot optimize access for said threads. However, that is also
it's strength, as Ruby threads need not make system calls to switch
between themselves. This actually results in faster running times in some
cases. Also, what Chris said is true, PThreads cannot take advantage of
multiple processor machines as native threads can.

> 
>> Does anybody know, if the Python and Perl Thread implementations are
>> similar to the ruby Thread implementation??
>

Python uses the same portable-thread-type scheme as Ruby. I know nothing
of Perl's threading mechanisms, or even if it has them.

> I'm not sure. Matz has hinted that Ruby 2.x will use native threads.
>

If Ruby is successfully ported to Parrot, it will have native thread
access. Parrot is supposed to implement native threading on all supported
platforms.

>> I tried to find some answers on the web but couldn't find anything
>> useful.
> <http://www.serpentine.com/~bos/threads-faq/> Sherlock rocks.

A good introduction to threading in general would probably be the
comp.programming.threads FAQ, found here:

http://www.serpentine.com/~bos/threads-faq/

Good luck! But watch out for those race conditions! ;-) (little thread
humor.... I know, I'm a geek)
-- 
I sense much NT in you.
NT leads to Bluescreen.
Bluescreen leads to downtime.
Downtime leads to suffering.
NT is the path to the darkside.
Powerful Unix is.