aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/erl_thr_progress.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/erts/emulator/beam/erl_thr_progress.c b/erts/emulator/beam/erl_thr_progress.c
index 9324bcde51..02f36fc75e 100644
--- a/erts/emulator/beam/erl_thr_progress.c
+++ b/erts/emulator/beam/erl_thr_progress.c
@@ -80,12 +80,12 @@
#ifdef ERTS_SMP
-/*
- * We use a 64-bit value for thread progress. By this wrapping of
- * the thread progress will more or less never occur.
- *
- * On 32-bit systems we therefore need a double word atomic.
- */
+#define ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE 0
+
+#ifdef DEBUG
+#undef ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE
+#define ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE 1
+#endif
#define ERTS_THR_PRGR_PRINT_LEADER 0
#define ERTS_THR_PRGR_PRINT_VAL 0
@@ -106,6 +106,13 @@
|ERTS_THR_PRGR_LFLG_ACTIVE_MASK)) \
== ERTS_THR_PRGR_LFLG_NO_LEADER)
+/*
+ * We use a 64-bit value for thread progress. By this wrapping of
+ * the thread progress will more or less never occur.
+ *
+ * On 32-bit systems we therefore need a double word atomic.
+ */
+
#define read_acqb erts_thr_prgr_read_acqb__
#ifdef ARCH_64
@@ -937,8 +944,10 @@ request_wakeup_managed(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
ASSERT(tpd->is_managed);
ASSERT(tpd->previous.local != ERTS_THR_PRGR_VAL_WAITING);
- if (has_reached_wakeup(value))
+ if (has_reached_wakeup(value)) {
wakeup_managed(tpd->id);
+ return;
+ }
wix = ERTS_THR_PRGR_WAKEUP_IX(value);
if (tpd->wakeup_request[wix] == value)
@@ -976,6 +985,10 @@ request_wakeup_managed(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
mwd = intrnl->managed.data[wix];
ix = erts_atomic32_inc_read_nob(&mwd->len) - 1;
+#if ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE
+ if (ix >= intrnl->managed.no)
+ erl_exit(ERTS_ABORT_EXIT, "Internal error: Too many wakeup requests\n");
+#endif
mwd->id[ix] = tpd->id;
ASSERT(!erts_thr_progress_has_reached(value));
@@ -1001,8 +1014,10 @@ request_wakeup_unmanaged(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
* we are writing the request.
*/
- if (has_reached_wakeup(value))
+ if (has_reached_wakeup(value)) {
wakeup_unmanaged(tpd->id);
+ return;
+ }
wix = ERTS_THR_PRGR_WAKEUP_IX(value);