aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_emu.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2019-03-29 16:45:31 +0100
committerSverker Eriksson <[email protected]>2019-03-29 16:45:31 +0100
commit97bd138d220bcb863a7e09dd420f879137c09a6c (patch)
treefc77e7d1775e13b8a4bd76e589bf058323804c6b /erts/emulator/beam/beam_emu.c
parent29aebc72390d351d3882f21e4c16b9f5b93e272f (diff)
parent2c8e6848d3b1d13529e83d8cf76e0a2a458fea52 (diff)
downloadotp-97bd138d220bcb863a7e09dd420f879137c09a6c.tar.gz
otp-97bd138d220bcb863a7e09dd420f879137c09a6c.tar.bz2
otp-97bd138d220bcb863a7e09dd420f879137c09a6c.zip
Merge branch 'sverker/process_info-reductions-fix/OTP-15709' into maint
* sverker/process_info-reductions-fix/OTP-15709: erts: Fix bug in process_info(reductions) erts: Use ptr_val for pointer in gc msg copy
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r--erts/emulator/beam/beam_emu.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 4351dda5a7..10d70a96e8 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -3261,20 +3261,23 @@ erts_is_builtin(Eterm Mod, Eterm Name, int arity)
/*
- * Return the current number of reductions for the given process.
+ * Return the current number of reductions consumed by the given process.
* To get the total number of reductions, p->reds must be added.
*/
Uint
-erts_current_reductions(Process *current, Process *p)
+erts_current_reductions(Process *c_p, Process *p)
{
- if (current != p) {
+ Sint reds_left;
+ if (c_p != p || !(erts_atomic32_read_nob(&c_p->state)
+ & ERTS_PSFLG_RUNNING)) {
return 0;
- } else if (current->fcalls < 0 && ERTS_PROC_GET_SAVED_CALLS_BUF(current)) {
- return current->fcalls + CONTEXT_REDS;
+ } else if (c_p->fcalls < 0 && ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) {
+ reds_left = c_p->fcalls + CONTEXT_REDS;
} else {
- return REDS_IN(current) - current->fcalls;
+ reds_left = c_p->fcalls;
}
+ return REDS_IN(c_p) - reds_left;
}
int