sanity-check for cpu thread

This commit is contained in:
Aaron Culliney 2014-03-30 10:57:56 -07:00
parent 5d552b445c
commit 52b087f805
4 changed files with 13 additions and 3 deletions

View File

@ -1106,7 +1106,12 @@ static void begin_cpu_step()
------------------------------------------------------------------------- */
bool c_debugger_should_break() {
// WARNING : this state management function should be called from CPU thread only!
if (pthread_self() != cpu_thread_id) {
// OOPS ...
ERRLOG("should only call this from cpu thread, bailing...");
void *ptr = NULL;
free(ptr);
}
if (at_haltpt()) {
stepping_struct.should_break = true;

View File

@ -824,8 +824,7 @@ int main(int sargc, char *sargv[])
c_initialize_firsttime(); /* init svga graphics and vm */
// spin off cpu thread
pthread_t thread1;
pthread_create(&thread1, NULL, (void *) &cpu_thread, (void *)NULL);
pthread_create(&cpu_thread_id, NULL, (void *) &cpu_thread, (void *)NULL);
// continue with main render thread
main_thread(NULL);

View File

@ -33,6 +33,7 @@ int gc_cycles_timer_0 = 0;
int gc_cycles_timer_1 = 0;
uint8_t emul_reinitialize;
pthread_t cpu_thread_id = 0;
static unsigned int g_nCyclesExecuted; // # of cycles executed up to last IO access
@ -156,6 +157,9 @@ void timing_initialize()
}
void cpu_thread(void *dummyptr) {
assert(pthread_self() == cpu_thread_id);
struct timespec deltat;
struct timespec t0; // the target timer
struct timespec ti, tj; // actual time samples

View File

@ -45,6 +45,8 @@ extern int g_nCpuCyclesFeedback;
extern double cpu_scale_factor;
extern double cpu_altscale_factor;
extern pthread_t cpu_thread_id;
extern int gc_cycles_timer_0;
extern int gc_cycles_timer_1;