Results 1 to 6 of 6
  1. #1
    A lowdown dirty shame blueshogun96's Avatar
    Join Date
    Aug 2005
    Location
    Puyallup, WA
    Posts
    196

    Question How to efficiently use threads in your emulator?

    Hey guys, I was wondering if some of you knew stuff about using threads. I've been trying to use threads in my emulator to simulate the emulation loop. Every time I use threads, they slow my emulator's performance to a crawl and kill my CPU usage. To be honest, I'm rather new at using threads, and is 4 threads too many? This sucks. Thanks.

    This is me and my PC everyday

    Need a good tutorial on emu programming? Click here. (Link Updated)
    Dynarec article
    Misc emu programming tidbits


    • Advertising

      advertising
      EmuTalk.net
      has no influence
      on the ads that
      are displayed
        
       

  2. #2
    Moderator
    Join Date
    Nov 2001
    Posts
    256
    threads have a lot of overhead in starting/stoping .. so depend on how you want to use them .. if you want to use them for short periods, write a thread pool class that has threads created and are just paused, pass them tasks to do.

    I found tho it is hard to really make use of threads in emulation cause if you care about the timing of things then you need to make sure things sync correctly, the over head in making sure everything syncs can be higher then the time you save executing in another thread.

    Threads will be come more important on dual/quad core cpus .. on single CPUs they will be a lot worse.

  3. #3
    A lowdown dirty shame blueshogun96's Avatar
    Join Date
    Aug 2005
    Location
    Puyallup, WA
    Posts
    196
    Ok, well, I don't have a dual/quad core CPU, so would there be a big performance hit if I just used one thread instead of the standard loop like in a game (which takes my CPU usage up to 100%)?
    This is me and my PC everyday

    Need a good tutorial on emu programming? Click here. (Link Updated)
    Dynarec article
    Misc emu programming tidbits

  4. #4
    Moderator
    Join Date
    Nov 2001
    Posts
    256
    things that respond to the mouse and user input is good to be in there own thread. Anything that is asleep 99% of the time, but needs to act quickly when you get a response from hardware is good for a thread.

    In a single CPU environment two threads running full ball is going to be worse then one thread just running. In a dual core environment tho, each one can have its own cpu and you will see a good speed increase.

  5. #5
    ????????????????????????? Doomulation's Avatar
    Join Date
    Nov 2001
    Location
    ????????????????
    Posts
    8,780
    Typically, you would want your GUI on one thread and emulation on one (or more). That will make sure your GUI is always responsive no matter what the emulation is doing.
    Though I would image threads would be a nightmare if used in such things as the core. Threads will be very useful when doing lengthy and costly operations. Otherwise you would need to split work between threads, and to make them synchronized, which zilmar already stated, has a costly overhead.
    Atashi wa juu-yon-sai no onna no ko! Atashi no namae wa Miizuki. Yurushiku ne!
    Nani? Atashi o shinjirimasen desu ka? Baka!
    "You're all doomed! Doomed, I say! Hehe... are we approaching the end of the world?"

    shikata ga kaite aru - "the instructions are written above"
    Need to download GoodN64 or instructions to use it? Need to check if it's a good or bad rom?
    Download: Glide64 | Hacktarux's wrapper

  6. #6
    Moderator smcd's Avatar
    Join Date
    Jun 2004
    Posts
    2,503
    As an example, MAME has only recently begun to consider multi core aspects (113u2 contains the first multi core aware driver)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •