dynamic context transitions

Russell Coker russell at coker.com.au
Thu Dec 2 01:46:33 GMT 2004


On Thursday 02 December 2004 10:12, "Christopher R. Hertel" <crh at ubiqx.mn.org> 
wrote:
> I've been asking about this in different places.  I've heard theories,
> mostly.  This is happening in Linux (dunno if it's been tested elsewhere)
> and one theory is that the forked process speeds are good because Linux
> basically does a really good job with those.  Meanwhile, thread speed is
> bad because the multiple threads are all within a single process and the
> single process gets only it's own share of processor time.

I believe that in Linux with the NPTL each thread gets scheduled independently 
by default.  Also if the threads were scheduled together then that would only 
cause problems if there were other programs using CPU time, in the case of a 
server running only a multi-threaded daemon it should not cause any problems.

> I don't know much about thread handling on Linux, but I would also imagine
> that there is a bit of an impact on all threads when one thread makes a
> system call.

For thread libraries that have application code implementing threads on top of 
a non-threaded libc or kernel (Green Threads for Java and every Ada runtime 
for DOS are the two best examples that I can think of) then a blocking system 
call in one thread will block all the other threads.

One problem with threads is that certain libc calls use locking when linked in 
a multi-threaded manner.  In version 1.9x of my Bonnie++ benchmark suite I 
have a test program called getc_putc to test this.  On older versions of 
glibc the performance difference between non-threaded and threaded versions 
of a program when calling getc() and putc() was significant.  Now it seems 
that there's hardly any difference.  I suspect that because of these changes 
to glibc and other changes that presumably accompanied them the difference 
betwen threaded and non-threaded programs for such things is much less than 
it used to be.

-- 
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


More information about the samba-technical mailing list