aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2011-05-10 21:12:05 +0200
committerRickard Green <[email protected]>2011-05-13 14:23:28 +0200
commit78ebe8aa3754fc8837ab3a6b0bc11d1e78275eef (patch)
treea2d4e660b73dfee4fbf25f091a9fc6b8787b62bc
parent3da283a85f73132e73ab911154c2c0ff8797d61d (diff)
downloadotp-78ebe8aa3754fc8837ab3a6b0bc11d1e78275eef.tar.gz
otp-78ebe8aa3754fc8837ab3a6b0bc11d1e78275eef.tar.bz2
otp-78ebe8aa3754fc8837ab3a6b0bc11d1e78275eef.zip
Use 32-bit atomic for port snapshot
-rw-r--r--erts/emulator/beam/bif.c2
-rw-r--r--erts/emulator/beam/global.h8
-rw-r--r--erts/emulator/beam/io.c6
3 files changed, 8 insertions, 8 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index fe8dcc4d8b..fe21e30d82 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -3282,7 +3282,7 @@ BIF_RETTYPE ports_0(BIF_ALIST_0)
erts_smp_atomic_set(&erts_dead_ports_ptr,
(erts_aint_t) (port_buf + erts_max_ports));
- next_ss = erts_smp_atomic_inctest(&erts_ports_snapshot);
+ next_ss = erts_smp_atomic32_inctest(&erts_ports_snapshot);
for (i = erts_max_ports-1; i >= 0; i--) {
Port* prt = &erts_port[i];
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index 18dc9f75d5..7dc5aa85e9 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -183,7 +183,7 @@ struct port {
process to get (line oriented I/O)*/
Uint32 status; /* Status and type flags */
int control_flags; /* Flags for port_control() */
- Uint32 snapshot; /* Next snapshot that port should be part of */
+ erts_aint32_t snapshot; /* Next snapshot that port should be part of */
struct reg_proc *reg;
ErlDrvPDL port_data_lock;
@@ -530,7 +530,7 @@ extern Port* erts_port;
extern Uint erts_max_ports;
extern Uint erts_port_tab_index_mask;
-extern erts_smp_atomic_t erts_ports_snapshot;
+extern erts_smp_atomic32_t erts_ports_snapshot;
extern erts_smp_atomic_t erts_dead_ports_ptr;
ERTS_GLB_INLINE void erts_may_save_closed_port(Port *prt);
@@ -540,12 +540,12 @@ ERTS_GLB_INLINE void erts_may_save_closed_port(Port *prt);
ERTS_GLB_INLINE void erts_may_save_closed_port(Port *prt)
{
ERTS_SMP_LC_ASSERT(erts_smp_lc_spinlock_is_locked(&prt->state_lck));
- if (prt->snapshot != erts_smp_atomic_read(&erts_ports_snapshot)) {
+ if (prt->snapshot != erts_smp_atomic32_read_acqb(&erts_ports_snapshot)) {
/* Dead ports are added from the end of the snapshot buffer */
Eterm* tombstone = (Eterm*) erts_smp_atomic_addtest(&erts_dead_ports_ptr,
-(erts_aint_t)sizeof(Eterm));
ASSERT(tombstone+1 != NULL);
- ASSERT(prt->snapshot == (Uint32) erts_smp_atomic_read(&erts_ports_snapshot) - 1);
+ ASSERT(prt->snapshot == erts_smp_atomic32_read(&erts_ports_snapshot) - 1);
*tombstone = prt->id;
}
/*else no ongoing snapshot or port was already included or created after snapshot */
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index 86f550310c..8c1126aa6e 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -189,7 +189,7 @@ typedef struct line_buf_context {
static erts_smp_spinlock_t get_free_port_lck;
static Uint last_port_num;
static Uint port_num_mask;
-erts_smp_atomic_t erts_ports_snapshot; /* Identifies the _next_ snapshot (not the ongoing) */
+erts_smp_atomic32_t erts_ports_snapshot; /* Identifies the _next_ snapshot (not the ongoing) */
static ERTS_INLINE void
@@ -422,7 +422,7 @@ setup_port(Port* prt, Eterm pid, erts_driver_t *driver,
erts_smp_runq_lock(runq);
erts_smp_port_state_lock(prt);
prt->status = ERTS_PORT_SFLG_CONNECTED | xstatus;
- prt->snapshot = (Uint32) erts_smp_atomic_read(&erts_ports_snapshot);
+ prt->snapshot = erts_smp_atomic32_read(&erts_ports_snapshot);
old_name = prt->name;
prt->name = new_name;
#ifdef ERTS_SMP
@@ -1293,7 +1293,7 @@ void init_io(void)
erts_port[i].port_data_lock = NULL;
}
- erts_smp_atomic_init(&erts_ports_snapshot, (erts_aint_t) 0);
+ erts_smp_atomic32_init(&erts_ports_snapshot, (erts_aint32_t) 0);
last_port_num = 0;
erts_smp_spinlock_init(&get_free_port_lck, "get_free_port");