Context switch time with threads

Philippe Chabrillange (Philippe.Chabrillange@lri.fr)
Thu, 30 Apr 1998 17:37:27 +0200


We try to compare context switching time for processes and for threads.

We use the same method as lmbench
(http://reality.sgi.com/employees/lm/lmbench/lmbench.html#TOC):
One token circulate in a ring of pipes (one pipe for each thread)
When a thread gets the token it does a work (a summing-up of an array of
the specified size (one array is allocated on each thread), then it
passes the token on to the next thread.
We execute several complete loops (about 30000) and we measure the time.
Then we substract the time for passing the token from one thread to
another.

The numbers we obtain on a P II 300 follow (with linuxthreads-0.71):

size (Kb) | number of procs | time (microseconds)
threads | processes
-------------------------------------------------
1 | 2 | 4 | 5
128 | 2 | 8 | 205
1 | 4 | 5 | 6
64 | 4 | 11 | 107
128 | 4 | 13 | 415
1 | 64 | 7 | 9
128 | 64 | 21 | 1063

You can see that time does not increase very much for threads.

Can anyone explain these numbers ?

Thank you for your help.

-- 
Philippe Chabrillange
Universite d'Orsay - LRI
e-mail: Philippe.Chabrillange@lri.fr

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu