Skip to main content
gamedev.net
🔒 Locked

multi-threading in multiplayer game code

Started by KingsRevenge 3 replies 750+ views
Original Post
KingsRevenge
KingsRevenge
What kind of a role would multi-threading have in MMORPG game code? How would it benefit the multiplayer code, what would be its PRO''s and Con''s? Eric Wright o0Programmer0o AcidRain Productions http://www.acidrainproductions.com
Eric Wright o0Programmer0o
JonStelly
JonStelly
Multithreading has the same tradeoffs in network programming as it does in any other situation. You give up simplicity in order to increase performance in a few key areas. Your question is a little too broad to give you a really good answer, and without a good grasp of how multithreading is commonly applied to network programming, the explanations wouldn''t really make much sense either.

If you want some good places to start, try looking into I/O Completion ports and Overlapped I/O as they relate to Winsock programming. The Completion port mechanism uses a thread-pool approach and it should give you some good ideas on the power of multithreading, and give you some more specific questions to ask about.
wrathgame
wrathgame
Hi,

My experiance of threads in MMORPG games is new as i have just added into my one but basically i found out that without threads winsock will only alow upto something like 64 connections.. after that it blocks any more :-/ Also i believe it frees up processor time when a threaded tcp connection is lagging the rest of the threads and main server code continue to execute in the background :-)

Cons = implementing it :-p and you also need to be carfull about syncronisation... ie imaging if 2 threads are running "at the same time" and both read the same data.. then one writes back to it and then the other writes over what the 1st wrote .. that could be a big problem. basically u need to have a method of locking data while one thread is using it :-)

hope that helps

- Tim
~ Tim
fingh
fingh
A good rule to live by is to keep each additional thread performing a very modular activity. This will protect you from headaches and help avoid excessive wait time for multiple resource objects.

Also keep your thread count down. Multithreading is only beneficial until the point that frequent context switching begins to eat away at your execution time. Multithreading is most advantageous if you have a system with multiple processors, as context switches are less burdensome.

Tim/Fingh

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.