Messages in this thread | | | From | "Sean Hunter" <> | Date | Fri, 17 Dec 1999 10:08:44 +0000 | Subject | Re: RasterMan on linux and threads |
| |
On Fri, Dec 17, 1999 at 09:53:38AM +0100, Borek Lupomesky wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Fri, 17 Dec 1999 jgarzik@mandrakesoft.com wrote: > > > Also threads right now under linux all run on the same processor so > > under linux there is NO speed advantage to threads. You just end up > > Is it really so?
Nope. He just doesn't know anything about scheduling (or threading). Moving a thread to a different processor is almost always a loss in the real world (ie except for very long-lived threads with one thread per proc on an otherwise idle box), because it means that not only do you have the cost of migrating the process to the other processor, but you lose cache-affinity (you need to save and restore as much context as seperate processes whereas if they share a processor, all the process data is in the processor cache for all threads to share without cache misses). It also means that other processes suffer, because your one multi-threaded process (in the case of 2-way SMP) would get twice as many context switches (each thread would need to get swapped in and out seperately per processor), and introduces lots of luvverly atomicity nasties, because process data (visible to all threads) needs to be available to all processors. Summary: Ouch.
The benefit of threading comes from the fact that things can be done while parts of your process are blocked waiting for other things to happen. You can do processing while blocked on a socket waiting for connections for example. Remember also that your process is constantly being scheduled on a processor and dropped. Multi-threaded processes have "more bites of the cherry" when it comes to scheduling, even on UP.
He would do well to remember the words of Dan Bernstein: "Don't speculate- benchmark".
Sean
- 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/
| |