diff --git a/src/keys.c b/src/keys.c index 21828e1b..61fe48be 100644 --- a/src/keys.c +++ b/src/keys.c @@ -27,7 +27,8 @@ extern unsigned char joy_button1; /* mutex used to synchronize between cpu and main threads */ pthread_mutex_t interface_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t interface_cond = PTHREAD_COND_INITIALIZER; +pthread_cond_t ui_thread_cond = PTHREAD_COND_INITIALIZER; +pthread_cond_t cpu_thread_cond = PTHREAD_COND_INITIALIZER; #ifdef LINUX_JOYSTICK #include diff --git a/src/keys.h b/src/keys.h index 2dafa73d..8ae08257 100644 --- a/src/keys.h +++ b/src/keys.h @@ -137,7 +137,8 @@ // ---------------------------------------------------------------------------- extern pthread_mutex_t interface_mutex; -extern pthread_cond_t interface_cond; +extern pthread_cond_t cpu_thread_cond; +extern pthread_cond_t ui_thread_cond; extern bool caps_lock; #ifdef LINUX_JOYSTICK @@ -147,7 +148,6 @@ extern int js_offset_x, js_offset_y; extern float js_adjustlow_x, js_adjustlow_y, js_adjusthigh_x, js_adjusthigh_y; #endif -void enter_debugger(void); int c_mygetch(int block); int c_rawkey(); void c_keys_set_key(int key); diff --git a/src/meta/debugger.c b/src/meta/debugger.c index 89ead9c0..9be52b0a 100644 --- a/src/meta/debugger.c +++ b/src/meta/debugger.c @@ -1082,10 +1082,10 @@ static void begin_cpu_step() int err = 0; do { - if ((err = pthread_cond_signal(&interface_cond))) { + if ((err = pthread_cond_signal(&cpu_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } - if ((err = pthread_cond_wait(&interface_cond, &interface_mutex))) { + if ((err = pthread_cond_wait(&ui_thread_cond, &interface_mutex))) { ERRLOG("pthread_cond_wait : %d", err); } @@ -1094,7 +1094,7 @@ static void begin_cpu_step() } } while (!stepping_struct.should_break); - if ((err = pthread_cond_signal(&interface_cond))) { + if ((err = pthread_cond_signal(&cpu_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } @@ -1384,7 +1384,7 @@ void c_interface_debugging() { c_interface_exit(-1); is_debugging = false; - if ((err = pthread_cond_signal(&interface_cond))) + if ((err = pthread_cond_signal(&cpu_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } diff --git a/src/timing.c b/src/timing.c index b6c13cc7..dc270e58 100644 --- a/src/timing.c +++ b/src/timing.c @@ -32,7 +32,7 @@ double cpu_altscale_factor = 1.0; int gc_cycles_timer_0 = 0; int gc_cycles_timer_1 = 0; -uint8_t emul_reinitialize; +uint8_t emul_reinitialize = 0; pthread_t cpu_thread_id = 0; static unsigned int g_nCyclesExecuted; // # of cycles executed up to last IO access @@ -230,10 +230,10 @@ void cpu_thread(void *dummyptr) { debugging_cycles -= cpu65_cycle_count; if (c_debugger_should_break() || (debugging_cycles <= 0)) { int err = 0; - if ((err = pthread_cond_signal(&interface_cond))) { + if ((err = pthread_cond_signal(&ui_thread_cond))) { ERRLOG("pthread_cond_signal : %d", err); } - if ((err = pthread_cond_wait(&interface_cond, &interface_mutex))) { + if ((err = pthread_cond_wait(&cpu_thread_cond, &interface_mutex))) { ERRLOG("pthread_cond_wait : %d", err); } if (debugging_cycles <= 0) {