Jon wrote:
Unless you're trying to emulate on a Propeller microcontroller (it has 8 wimpy cores) I don't see much point in going multithreaded.
I'm always arguing against going multithreaded at work for otherwise trivial tasks, it's one of those rookie developer mistakes (among using other "cool" technologies/buzzwords where they are inappropriate). It just wastes memory(more stacks), can cause context switch thrashing, and rarely improves performance. Threads can (and do) improve scalability. But a NES emulator is not exactly a problem looking for a scalable solution.
It is rare that I see a multithreaded solution to a problem that is less complex than a single threaded one. Avoiding complexity can keep you from landing in debugger hell.
Now if you just want to do it to do it, that's another story, and I can totally related to that. I won't stop you from doing something for the sake of it, just don't try to convince me that it is better without some solid data to back up the claims. (not that you made any claims)
I'm also don't like to use BUZZWORD I have a couple of articles published on magazines talking about buzzwords ... fancy developer... I just wondering the two threads by what I've read...
I agree with you that multithread can made slower the nes emulator... but in some cases as game cube or ps2 (or even the psp) emulators the multithread is needed and improve the speed too.
"It is rare that I see a multithreaded solution to a problem that is less complex than a single threaded one"
Perfect sentence to...
Now I got just one thread (logically that swing has yours own) the Emulator one on my run method.
Code:
public void run(){
while (running){
while (cpu.cycles < 114){ // 114 is the HBLANK or Scanline time
cpu.step();
}
ppu.scanline(); //do 240 scanlines then
// + 3 scanlines and enter on VBLANK timming
// wait more 20 scanlines timming to exit the VBLANK
}
}