[MUD-Dev] Multithreaded sockets

Sean Kelly sean at ffwd.cx
Mon Jun 3 07:32:23 CEST 2002


From: "Draymoor a Vin il'Rogina" <draymoor at cloud9.net>

> I was looking through the archives and came across a post in which
> it was suggested that a thread for game logic and a thread for
> descriptor input would be ideal, on a dual processor
> machine. Right now, I have a thread for each descriptor to recieve
> input from blocking sockets, a thread to accept new descriptors
> and parse input, and a thread for the game logic. I'm running on a
> single processor machine, though hopefully soon it'll be a double
> processor.  Is having this many threads a bad idea?

If you are planning to scale very far, particular on a Windows
machine, then yes.  There is cost for context switching, and with a
high connection count your CPU may be spending nearly as much time
switching between threads as it spends in the threads themselves.
This isn't a very efficient use of resources.  Problem is, the best
way to overcome this is really platform-dependent.  In Windows, it's
IOCP.  I believe that Linux also has a similar kernel-level
signaling architecture now, too.  Barring that, there's always
select and nonblocking sockets.

Sean

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list