summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/code_ix.h
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam/code_ix.h')
-rw-r--r--erts/emulator/beam/code_ix.h74
1 files changed, 57 insertions, 17 deletions
diff --git a/erts/emulator/beam/code_ix.h b/erts/emulator/beam/code_ix.h
index f557ff2980..54ceefcc9b 100644
--- a/erts/emulator/beam/code_ix.h
+++ b/erts/emulator/beam/code_ix.h
@@ -121,7 +121,6 @@ typedef struct ErtsCodeInfo_ {
typedef struct {
erts_refc_t pending_schedulers;
ErtsThrPrgrLaterOp later_op;
- void *esdp;
UWord size;
void (*later_function)(void *);
@@ -158,37 +157,76 @@ ErtsCodeIndex erts_active_code_ix(void);
/* Return staging code ix.
* Only used by a process performing code loading/upgrading/deleting/purging.
- * Code write permission must be seized.
+ * Code staging permission must be seized.
*/
ERTS_GLB_INLINE
ErtsCodeIndex erts_staging_code_ix(void);
-/* Try seize exclusive code write permission. Needed for code staging.
+/** @brief Try to seize exclusive code loading permission. That is, both
+ * staging and modification permission.
+ *
* Main process lock (only) must be held.
* System thread progress must not be blocked.
- * Caller must not already hold the code write permission.
- * Caller is suspended and *must* yield if 0 is returned.
+ * Caller must not already have the code modification or staging permissions.
+ * Caller is suspended and *must* yield if 0 is returned. */
+int erts_try_seize_code_load_permission(struct process* c_p);
+
+/** @brief Release code loading permission. Resumes any suspended waiters. */
+void erts_release_code_load_permission(void);
+
+/** @brief Try to seize exclusive code staging permission. Needed for code
+ * loading and purging.
+ *
+ * This is kept separate from code modification permission to allow tracing and
+ * similar during long-running purge operations.
+ *
+ * * Main process lock (only) must be held.
+ * * System thread progress must not be blocked.
+ * * Caller is suspended and *must* yield if 0 is returned.
+ * * Caller must not already have the code modification or staging permissions.
+ *
+ * That is, it is _NOT_ possible to add code modification permission when you
+ * already have staging permission. The other way around is fine however.
+ */
+int erts_try_seize_code_stage_permission(struct process* c_p);
+
+/** @brief Release code stage permission. Resumes any suspended waiters. */
+void erts_release_code_stage_permission(void);
+
+/** @brief Try to seize exclusive code modification permission. Needed for
+ * tracing, breakpoints, and so on.
+ *
+ * This used to be called code_write_permission, but was renamed to break
+ * merges of code that uses the old locking paradigm.
+ *
+ * * Main process lock (only) must be held.
+ * * System thread progress must not be blocked.
+ * * Caller is suspended and *must* yield if 0 is returned.
+ * * Caller must not already have the code modification permission, but may
+ * have staging permission.
*/
-int erts_try_seize_code_write_permission(struct process* c_p);
+int erts_try_seize_code_mod_permission(struct process* c_p);
-/* Try seize exclusive code write permission for aux work.
+/** @brief As \c erts_try_seize_code_mod_permission but for aux work.
+ *
* System thread progress must not be blocked.
* On success return true.
* On failure return false and aux work func(arg) will be scheduled when
- * permission is released. .
+ * permission is released.
*/
-int erts_try_seize_code_write_permission_aux(void (*func)(void *),
- void *arg);
+int erts_try_seize_code_mod_permission_aux(void (*func)(void *),
+ void *arg);
-/* Release code write permission.
- * Will resume any suspended waiters.
- */
-void erts_release_code_write_permission(void);
+/** @brief Release code modification permission. Resumes any suspended
+ * waiters. */
+void erts_release_code_mod_permission(void);
/* Prepare the "staging area" to be a complete copy of the active code.
- * Code write permission must have been seized.
+ *
+ * Code staging permission must have been seized.
+ *
* Must be followed by calls to either "end" and "commit" or "abort" before
- * code write permission can be released.
+ * code staging permission can be released.
*/
void erts_start_staging_code_ix(int num_new);
@@ -234,7 +272,9 @@ void erts_blocking_code_barrier(void);
void erts_code_ix_finalize_wait(void);
#ifdef ERTS_ENABLE_LOCK_CHECK
-int erts_has_code_write_permission(void);
+int erts_has_code_load_permission(void);
+int erts_has_code_stage_permission(void);
+int erts_has_code_mod_permission(void);
#endif
/* module/function/arity can be NIL/NIL/-1 when the MFA is pointing to some