aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/emulator/beam/beam_bif_load.c24
-rw-r--r--erts/emulator/beam/beam_debug.c4
-rw-r--r--erts/emulator/beam/code_ix.c12
-rw-r--r--erts/emulator/beam/code_ix.h25
-rw-r--r--erts/emulator/beam/erl_bif_trace.c10
-rw-r--r--erts/emulator/beam/erl_init.c2
-rw-r--r--erts/emulator/beam/erl_nif.c4
-rw-r--r--erts/emulator/beam/erl_process.c4
8 files changed, 41 insertions, 44 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index fbab59f794..e06fe52c36 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -72,7 +72,7 @@ BIF_RETTYPE code_make_stub_module_3(BIF_ALIST_3)
Module* modp;
Eterm res;
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD3(bif_export[BIF_code_make_stub_module_3],
BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3);
}
@@ -94,14 +94,14 @@ BIF_RETTYPE code_make_stub_module_3(BIF_ALIST_3)
if (res == BIF_ARG_1) {
erts_end_staging_code_ix();
- erts_activate_staging_code_ix();
+ erts_commit_staging_code_ix();
}
else {
erts_abort_staging_code_ix();
}
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
return res;
}
@@ -177,7 +177,7 @@ finish_loading_1(BIF_ALIST_1)
int is_blocking = 0;
int do_commit = 0;
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD1(bif_export[BIF_finish_loading_1], BIF_P, BIF_ARG_1);
}
@@ -324,7 +324,7 @@ staging_epilogue(Process* c_p, int commit, Eterm res, int is_blocking)
{
if (commit) {
erts_end_staging_code_ix();
- erts_activate_staging_code_ix();
+ erts_commit_staging_code_ix();
}
else {
erts_abort_staging_code_ix();
@@ -333,7 +333,7 @@ staging_epilogue(Process* c_p, int commit, Eterm res, int is_blocking)
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(c_p, ERTS_PROC_LOCK_MAIN);
}
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
return res;
}
#ifdef ERTS_SMP
@@ -461,7 +461,7 @@ BIF_RETTYPE delete_module_1(BIF_ALIST_1)
BIF_ERROR(BIF_P, BADARG);
}
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD1(bif_export[BIF_delete_module_1], BIF_P, BIF_ARG_1);
}
@@ -572,7 +572,7 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2)
Module* modp;
Eterm on_load;
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD2(bif_export[BIF_finish_after_on_load_2],
BIF_P, BIF_ARG_1, BIF_ARG_2);
}
@@ -589,7 +589,7 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2)
error:
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
BIF_ERROR(BIF_P, BADARG);
}
if ((on_load = modp->curr.code[MI_ON_LOAD_FUNCTION_PTR]) == 0) {
@@ -639,7 +639,7 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2)
}
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
BIF_RET(am_true);
}
@@ -898,7 +898,7 @@ BIF_RETTYPE purge_module_1(BIF_ALIST_1)
BIF_ERROR(BIF_P, BADARG);
}
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD1(bif_export[BIF_purge_module_1], BIF_P, BIF_ARG_1);
}
@@ -959,7 +959,7 @@ BIF_RETTYPE purge_module_1(BIF_ALIST_1)
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
}
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
return ret;
}
diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c
index d288a37911..e69cbc3048 100644
--- a/erts/emulator/beam/beam_debug.c
+++ b/erts/emulator/beam/beam_debug.c
@@ -114,7 +114,7 @@ erts_debug_breakpoint_2(BIF_ALIST_2)
mfa[2] = signed_val(mfa[2]);
}
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD2(bif_export[BIF_erts_debug_breakpoint_2],
BIF_P, BIF_ARG_1, BIF_ARG_2);
}
@@ -129,7 +129,7 @@ erts_debug_breakpoint_2(BIF_ALIST_2)
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(p, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
return res;
error:
diff --git a/erts/emulator/beam/code_ix.c b/erts/emulator/beam/code_ix.c
index def7e164e2..9158d2d05c 100644
--- a/erts/emulator/beam/code_ix.c
+++ b/erts/emulator/beam/code_ix.c
@@ -75,7 +75,7 @@ void erts_end_staging_code_ix(void)
CIX_TRACE("end");
}
-void erts_activate_staging_code_ix(void)
+void erts_commit_staging_code_ix(void)
{
ErtsCodeIndex ix;
/* We need to this lock as we are now making the staging export table active */
@@ -98,14 +98,14 @@ void erts_abort_staging_code_ix(void)
}
-/* Try lock code_ix
+/*
* Calller _must_ yield if we return 0
*/
-int erts_try_lock_code_ix(Process* c_p)
+int erts_try_seize_code_write_permission(Process* c_p)
{
int success;
- ASSERT(!erts_smp_thr_progress_is_blocking());
+ ASSERT(!erts_smp_thr_progress_is_blocking()); /* to avoid deadlock */
erts_smp_mtx_lock(&the_code_ix_queue_lock);
success = !the_code_ix_lock;
@@ -125,9 +125,7 @@ int erts_try_lock_code_ix(Process* c_p)
return success;
}
-/* Unlock code_ix (resume all waiters)
-*/
-void erts_unlock_code_ix(void)
+void erts_release_code_write_permission(void)
{
erts_smp_mtx_lock(&the_code_ix_queue_lock);
while (the_code_ix_queue != NULL) { /* unleash the entire herd */
diff --git a/erts/emulator/beam/code_ix.h b/erts/emulator/beam/code_ix.h
index c37a5fe8f4..068ff0e6ba 100644
--- a/erts/emulator/beam/code_ix.h
+++ b/erts/emulator/beam/code_ix.h
@@ -81,38 +81,37 @@ ErtsCodeIndex erts_active_code_ix(void);
ERTS_GLB_INLINE
ErtsCodeIndex erts_staging_code_ix(void);
-/* Try lock code_ix that is needed for (exlusive) access of the staging area.
+/* Try seize exclusive code write permission. Needed for code staging.
* Main process lock (only) must be held.
* System thread progress must not be blocked.
* Caller is suspended and *must* yield if 0 is returned.
*/
-int erts_try_lock_code_ix(struct process*);
+int erts_try_seize_code_write_permission(struct process*);
-/* Unlock code_ix
+/* Release code write permission.
+ * Will resume any suspended waiters.
*/
-void erts_unlock_code_ix(void);
+void erts_release_code_write_permission(void);
/* Prepare the "staging area" to be a complete copy of the active code.
- * code_ix must be locked.
- * Must be followed by calls to either "end" and "activate" or "abort" before
- * code_ix lock is released.
+ * Code write permission must have been seized.
+ * Must be followed by calls to either "end" and "commit" or "abort" before
+ * code write permission can be released.
*/
void erts_start_staging_code_ix(void);
/* End the staging.
- * code_ix must be locked.
- * Must be followed by a call to either "activate" or "abort"
- * before code_ix lock is released.
+ * Preceded by "start" and followed by "commit" or "abort".
*/
void erts_end_staging_code_ix(void);
/* Set staging code index as new active code index.
- * code_ix must be locked and "start" and "end" called.
+ * Preceded by "end".
*/
-void erts_activate_staging_code_ix(void);
+void erts_commit_staging_code_ix(void);
/* Abort the staging.
- * code_ix must be locked and "start" called.
+ * Preceded by "start" or "end".
*/
void erts_abort_staging_code_ix(void);
diff --git a/erts/emulator/beam/erl_bif_trace.c b/erts/emulator/beam/erl_bif_trace.c
index 6f04787478..1c99fcdaa6 100644
--- a/erts/emulator/beam/erl_bif_trace.c
+++ b/erts/emulator/beam/erl_bif_trace.c
@@ -108,7 +108,7 @@ trace_pattern(Process* p, Eterm MFA, Eterm Pattern, Eterm flaglist)
Process *meta_tracer_proc = p;
Eterm meta_tracer_pid = p->id;
- if (!erts_try_lock_code_ix(p)) {
+ if (!erts_try_seize_code_write_permission(p)) {
ERTS_BIF_YIELD3(bif_export[BIF_trace_pattern_3], p, MFA, Pattern, flaglist);
}
erts_smp_proc_unlock(p, ERTS_PROC_LOCK_MAIN);
@@ -338,7 +338,7 @@ trace_pattern(Process* p, Eterm MFA, Eterm Pattern, Eterm flaglist)
UnUseTmpHeap(3,p);
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(p, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
if (matches >= 0) {
return make_small(matches);
@@ -464,7 +464,7 @@ Eterm trace_3(BIF_ALIST_3)
BIF_ERROR(p, BADARG);
}
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
ERTS_BIF_YIELD3(bif_export[BIF_trace_3], BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3);
}
@@ -732,7 +732,7 @@ Eterm trace_3(BIF_ALIST_3)
erts_smp_proc_lock(p, ERTS_PROC_LOCK_MAIN);
}
#endif
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
BIF_RET(make_small(matches));
@@ -748,7 +748,7 @@ Eterm trace_3(BIF_ALIST_3)
erts_smp_proc_lock(p, ERTS_PROC_LOCK_MAIN);
}
#endif
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
BIF_ERROR(p, BADARG);
}
diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c
index a4690891d5..4db23a0a18 100644
--- a/erts/emulator/beam/erl_init.c
+++ b/erts/emulator/beam/erl_init.c
@@ -1474,7 +1474,7 @@ erl_start(int argc, char **argv)
init_shared_memory(boot_argc, boot_argv);
load_preloaded();
erts_end_staging_code_ix();
- erts_activate_staging_code_ix();
+ erts_commit_staging_code_ix();
erts_initialized = 1;
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index a0182630b9..bdbeb3bcf6 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1522,7 +1522,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
}
lib_name[len] = '\0';
- if (!erts_try_lock_code_ix(BIF_P)) {
+ if (!erts_try_seize_code_write_permission(BIF_P)) {
erts_free(ERTS_ALC_T_TMP, lib_name);
ERTS_BIF_YIELD2(bif_export[BIF_load_nif_2],
BIF_P, BIF_ARG_1, BIF_ARG_2);
@@ -1722,7 +1722,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
erts_free(ERTS_ALC_T_TMP, lib_name);
if (reload_warning) {
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index aaee951107..a7707e9498 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -1178,7 +1178,7 @@ handle_code_ix_activation(ErtsAuxWorkData *awdp, erts_aint32_t aux_work)
#endif
erts_smp_proc_lock(p, ERTS_PROC_LOCK_STATUS);
if (!ERTS_PROC_IS_EXITING(p)) {
- erts_activate_staging_code_ix();
+ erts_commit_staging_code_ix();
erts_resume(p, ERTS_PROC_LOCK_STATUS);
erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
}
@@ -1186,7 +1186,7 @@ handle_code_ix_activation(ErtsAuxWorkData *awdp, erts_aint32_t aux_work)
erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS);
erts_abort_staging_code_ix();
}
- erts_unlock_code_ix();
+ erts_release_code_write_permission();
erts_smp_proc_dec_refc(p);
return aux_work & ~ERTS_SSI_AUX_WORK_CODE_IX_ACTIVATION;
}