Thread Usage

This is a discussion on Thread Usage within the Game Programming forums, part of the General Programming Boards category; Hi, Just wondering what threads are typically useful for in games. I figured there could be separate threads for window ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Thread Usage

    Hi,
    Just wondering what threads are typically useful for in games. I figured there could be separate threads for window management, game logic, graphics, and networking; but then, I know that thread synchronization causes a lot of problems in general, so I'd like to hear some thoughts from people with more experience in this matter.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    So far in my engine I have avoided using threads. They have given me fits before and I don't want to mess with them just yet.

    But I plan on using threads for:

    • Sound
    • Keyboard
    • Network


    The rendering will stay in the main thread. I'm not sure about OGL but Direct3D does not do well if it's not in the main thread. It can be done if every object being rendered is also in the same thread and no objects outside of the thread need to render.

    The above components would work because none of them need to render and therefore do not depend on OGL/Direct3D. You may still get synchro issues with input coming after/before rendering.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Thanks, Bubba.

    How are you dealing with networking in your engine? I was thinking of just transmitting all keyboard events (no mouse involved), imposing a latency of ~0.1s (possibly dependent on ping) on execution of events, and keeping a few snapshots of gamestate history to revert in case packets arrive late.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Threads are generally very useful in multi-core systems. And CPU tend to have more and more cores. Since frequency and transistor size are reaching their limits, there will be sure some changes int he way people program in the feature. One will be using threads. Other might be using GPU (nvidia already started that).

    I asked once a guy that worked in blizzard about if they use threads in their game to take advantage of multicore processors. They didn't., at least extensively. Though he mentioned another company that have done it, separating the "game world" among threads. I assume that using extensively threads in a very big project, as a commercial game, will make it more complicated.

    But undoubtly, using threads for computing a large data block, which is common in games, is really advantageous.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    But undoubtly, using threads for computing a large data block, which is common in games, is really advantageous.
    I would consider the advantages to be logarithmic. There would be a point where the number of threads being used outweighed any advantages they offered. So as in all things a balance is important.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2009, 10:48 PM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 04:14 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21