From 41cf0cb977472a15527b6ac693883daaa84faa5a Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Tue, 17 Jan 2012 11:18:26 +0100 Subject: erts: First stab at code_ix interface and beam_catches using it Code loading still blocking --- erts/emulator/beam/global.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'erts/emulator/beam/global.h') diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h index 46bc58891b..8745ca610b 100644 --- a/erts/emulator/beam/global.h +++ b/erts/emulator/beam/global.h @@ -28,6 +28,50 @@ #include "hash.h" #include "index.h" #include "atom.h" + +/*SVERK maybe put this is some other header, must be before module.h and export.h */ +#define ERTS_NUM_CODE_IX 3 +typedef unsigned ErtsCodeIndex; + +void erts_code_ix_init(void); +ErtsCodeIndex erts_active_code_ix(void); +ErtsCodeIndex erts_loader_code_ix(void); + +/* Lock code_ix (enqueue and suspend until we get it) +*/ +void erts_lock_code_ix(void); + +/*SVERK + erts_lock_code_ix(); + wait for thread progress + (we don't want any retarded threads with pointers to inactive Module) + Copy active -> loader + rlock old_code while copying Modules + Update loader + wait for thread progress + (we need a membarrier for everybody to "see" the new code) + Set loader as new active + erts_unlock_code_ix(); +}*/ + + +/* Unlock code_ix (resume first waiter) +*/ +void erts_unlock_code_ix(void); +void erts_start_loader_code_ix(void); +void erts_commit_loader_code_ix(void); +void erts_abort_loader_code_ix(void); + +void erts_rwlock_old_code(void); +void erts_rwunlock_old_code(void); +void erts_rlock_old_code(void); +void erts_runlock_old_code(void); + +#ifdef ERTS_ENABLE_LOCK_CHECK +int erts_is_old_code_rlocked(void); +int erts_is_code_ix_locked(void); +#endif + #include "export.h" #include "module.h" #include "register.h" -- cgit v1.2.3