From 964b17761669f25417228c8fa1e362b451c5f404 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 16 Feb 2020 17:15:49 -0800 Subject: [PATCH] SCP: Fix potential hang during debug when asynchronous I/O is happening --- sim_defs.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sim_defs.h b/sim_defs.h index a60fad3d..17b90ff6 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -1090,7 +1090,11 @@ extern int32 sim_asynch_latency; extern int32 sim_asynch_inst_latency; /* Thread local storage */ -#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__hpux) && !defined(__OpenBSD__) && !defined(_AIX) +#if defined(thread_local) +#define AIO_TLS thread_local +#elif (__STDC_VERSION__ >= 201112) && !(defined(__STDC_NO_THREADS__)) +#define AIO_TLS _Thread_local +#elif defined(__GNUC__) && !defined(__APPLE__) && !defined(__hpux) && !defined(__OpenBSD__) && !defined(_AIX) #define AIO_TLS __thread #elif defined(_MSC_VER) #define AIO_TLS __declspec(thread) @@ -1255,7 +1259,11 @@ extern int32 sim_asynch_inst_latency; sim_asynch_queue = uptr; \ } \ if (sim_idle_wait) { \ - sim_debug (TIMER_DBG_IDLE, &sim_timer_dev, "waking due to event on %s after %d instructions\n", sim_uname(uptr), event_time);\ + if (sim_deb) { /* only while debug do lock/unlock overhead */ \ + AIO_UNLOCK; \ + sim_debug (TIMER_DBG_IDLE, &sim_timer_dev, "waking due to event on %s after %d instructions\n", sim_uname(uptr), event_time);\ + AIO_LOCK; \ + } \ pthread_cond_signal (&sim_asynch_wake); \ } \ AIO_UNLOCK; \