aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/register.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2012-02-27 18:45:47 +0100
committerRickard Green <[email protected]>2012-04-27 12:41:57 +0200
commit4bcffe41e193bfa03f54f77e2158b3d989a001d0 (patch)
tree322a8c6f5f7de2458b0fbd274cb5356a76689519 /erts/emulator/beam/register.c
parent414f4fb8dc9a188f8148a1f92e5f9125108e170d (diff)
downloadotp-4bcffe41e193bfa03f54f77e2158b3d989a001d0.tar.gz
otp-4bcffe41e193bfa03f54f77e2158b3d989a001d0.tar.bz2
otp-4bcffe41e193bfa03f54f77e2158b3d989a001d0.zip
Optimize process state changes
Diffstat (limited to 'erts/emulator/beam/register.c')
-rw-r--r--erts/emulator/beam/register.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/erts/emulator/beam/register.c b/erts/emulator/beam/register.c
index 0ddae56322..c02872ef80 100644
--- a/erts/emulator/beam/register.c
+++ b/erts/emulator/beam/register.c
@@ -93,14 +93,14 @@ reg_safe_write_lock(Process *c_p, ErtsProcLocks *c_p_locks)
reg_write_lock();
}
+#endif
+
static ERTS_INLINE int
is_proc_alive(Process *p)
{
return !ERTS_PROC_IS_EXITING(p);
}
-#endif
-
void register_info(int to, void *to_arg)
{
int lock = !ERTS_IS_CRASH_DUMPING;
@@ -384,8 +384,7 @@ erts_whereis_name(Process *c_p,
}
#else
if (rp->p
- && ((flags & ERTS_P2P_FLG_ALLOW_OTHER_X)
- || rp->p->status != P_EXITING))
+ && ((flags & ERTS_P2P_FLG_ALLOW_OTHER_X) || is_proc_alive(rp->p)))
*proc = rp->p;
else
*proc = NULL;
@@ -397,7 +396,9 @@ erts_whereis_name(Process *c_p,
if (!rp || !rp->pt)
*port = NULL;
else {
-#ifdef ERTS_SMP
+#ifndef ERTS_SMP
+ erts_smp_atomic_inc_nob(&rp->pt->refc);
+#else
if (pending_port == rp->pt)
pending_port = NULL;
else {
@@ -504,9 +505,11 @@ int erts_unregister_name(Process *c_p,
if ((rp = (RegProc*) hash_get(&process_reg, (void*) &r)) != NULL) {
if (rp->pt) {
if (port != rp->pt) {
-#ifdef ERTS_SMP
+#ifndef ERTS_SMP
+ erts_smp_atomic_inc_nob(&rp->pt->refc);
+#else
if (port) {
- ERTS_SMP_LC_ASSERT(port != c_prt);
+ ASSERT(port != c_prt);
erts_smp_port_unlock(port);
port = NULL;
}