diff options
-rw-r--r-- | erts/emulator/beam/erl_process.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index d3a4b72395..88011d70d2 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -6932,13 +6932,25 @@ schedule_process_sys_task(Process *p, erts_aint32_t prio, ErtsProcSysTask *st, { erts_aint32_t fail_state, state; + fail_state = *fail_state_p; + /* Elevate priority if needed. */ - state = erts_atomic32_read_nob(&p->state); - if (ERTS_PSFLGS_GET_ACT_PRIO(state) > prio) { + state = erts_atomic32_read_acqb(&p->state); + if (ERTS_PSFLGS_GET_ACT_PRIO(state) <= prio) { + if (state & fail_state) { + *fail_state_p = state & fail_state; + return 0; + } + } + else { erts_aint32_t n, a, e; a = state; do { + if (a & fail_state) { + *fail_state_p = a & fail_state; + return 0; + } if (ERTS_PSFLGS_GET_ACT_PRIO(a) <= prio) { n = a; break; @@ -6952,8 +6964,6 @@ schedule_process_sys_task(Process *p, erts_aint32_t prio, ErtsProcSysTask *st, state = n; } - fail_state = *fail_state_p; - return !(active_sys_enqueue(p, st, prio, ERTS_PSFLG_SYS_TASKS, state, fail_state_p) & fail_state); } @@ -10727,7 +10737,7 @@ request_system_task(Process *c_p, Eterm requester, Eterm target, Eterm priority, Eterm operation) { BIF_RETTYPE ret; - Process *rp = erts_proc_lookup(target); + Process *rp = erts_proc_lookup_raw(target); ErtsProcSysTask *st = NULL; erts_aint32_t prio, fail_state = ERTS_PSFLG_EXITING; Eterm noproc_res, req_type; |