lkml.org 
[lkml]   [1999]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectlinux threads vs. solaris threads

Hi

Few days ago in my concurrent programming class the teacher stated
that the time it takes the OS to switch between threads (i.e. threads
created with pthreads_create()/clone(CLONE_VM|CLONE_FILES etc)) was
probably higher in Linux than in Solaris (and other commercial Unices)
on the same hardware.
He based his assumption on the fact that a Linux thread is actually
a process (seen with the eyes of the kernel) and the Linux kernel
doesn't have the concept of a thread as Solaris. Therefore Linux has
to switch contexts when switching between threads but Solaris doesn't
have to do a context switch as the threads were running in the same
context (and no we were not confusing Linux threads and Solaris
userspace threads, we were talking about kernel level threads in
both systems).
He added that he didn't have any data or couldn't reference
any source to back up his claim so he might be wrong.

I found his statement interesting as I recalled seeing somewhere that
switching between processes (and threads) in Linux took less time than
switching between processes in Solaris. I decided to try to figure
out if his statement was true.

I found the lmbench benchmark that tries to measure the time it takes
to do a context switch. Checking the lmbench source shows that it
creates new processes with fork() and measures the time it takes
to do a context switch between them. I don't think that this measurement
is a fair measurement for the time it takes to switch between threads
as there is no need to flush the TLB wich has to be done when doing a
switch between processes if I have understood the purpose of a TLB
correctly (but I might be wrong as I dont understand this well enough).
So I concluded that lmbench was not the right tool to measure this and
answer my question.

As far as I understand, switching between threads in Linux means
changing the PC counter, the stackpointer and restoring the registers
and FP state. Solaris probably does something similar.

Can anyone here help me determine if my teacher is right or wrong on
this (or isn't there a right/wrong answer? :) or point me
to webpages, articles, books or benchmarking tools?
Also, is there any more "context switch" involved in switching
between threads in Linux than in Solaris? A Linux thread
created with the clone() system call has the same virtual
memory and same file descriptors as other threads running
with it within the same process so there isn't really any
context to switch between except changing the state of
the CPU.

Thanks in advance for your time and your help.

Hrafnkell
--
//-----------------------//-------------------------------------------------
// Hrafnkell Eiriksson //
// he@kvintus.dk //
// TF3HR // "Blessed are they who go around in circles,
// // for they shall be known as Wheels"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.089 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site