[MUD-Dev] Multi-threaded mud server.

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Wed May 19 22:15:22 CEST 1999


[Jo Dillon:]

>   Isn't the point that every time you context switch you invalidate the
> cache (since the new thread of execution will be in a different chunk of
> memory to the old one), and therefore if you have more threads than 
> processors you context-switch <bignum> times a second, therefore constantly 
> invalidating your cache and giving yourself a big speed hit?

Not really. The OS will maintain some small data structure for each
thread, but that's likely a small blip in the cache. If multiple threads
are executing the same code, then they will all benefit from hits in
the instruction cache (I-cache). If they are not, then then will not
get that benefit, but the same thing happens even if you don't use
multiple threads, since all of those instructions needed to be executed
one way or another. The only way you would suffer noticeably is if the
OS had a too small time-slice, and so flipped between threads executing
completely different code sets too often. The same sort of issues work
with the data cache (D-cache) if that is separate in your CPU. Note
that off-chip caches are usually (always?) integrated I and D caches.

We're likely starting to get off-topic here! I bet Marion isn't reading
this stuff anymore. :-)

--
Don't design inefficiency in - it'll happen in the implementation.

Chris Gray     cg at ami-cg.GraySage.Edmonton.AB.CA
               http://www.GraySage.Edmonton.AB.CA/cg/


_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the mud-dev-archive mailing list