aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/common/erl_mseg.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/sys/common/erl_mseg.c')
-rw-r--r--erts/emulator/sys/common/erl_mseg.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/erts/emulator/sys/common/erl_mseg.c b/erts/emulator/sys/common/erl_mseg.c
index f4e21bc05f..5dfd66bd7c 100644
--- a/erts/emulator/sys/common/erl_mseg.c
+++ b/erts/emulator/sys/common/erl_mseg.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2002-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2002-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -287,13 +287,9 @@ check_schedule_cache_check(void)
static void
mseg_shutdown(void)
{
-#ifdef ERTS_SMP
erts_mtx_lock(&mseg_mutex);
-#endif
mseg_clear_cache();
-#ifdef ERTS_SMP
erts_mtx_unlock(&mseg_mutex);
-#endif
}
static ERTS_INLINE void *
@@ -375,8 +371,9 @@ mseg_recreate(void *old_seg, Uint old_size, Uint new_size)
static ERTS_INLINE cache_desc_t *
alloc_cd(void)
-{
+{
cache_desc_t *cd = free_cache_descs;
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
if (cd)
free_cache_descs = cd->next;
return cd;
@@ -385,6 +382,7 @@ alloc_cd(void)
static ERTS_INLINE void
free_cd(cache_desc_t *cd)
{
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
cd->next = free_cache_descs;
free_cache_descs = cd;
}
@@ -393,6 +391,7 @@ free_cd(cache_desc_t *cd)
static ERTS_INLINE void
link_cd(cache_desc_t *cd)
{
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
if (cache)
cache->prev = cd;
cd->next = cache;
@@ -410,6 +409,7 @@ link_cd(cache_desc_t *cd)
static ERTS_INLINE void
end_link_cd(cache_desc_t *cd)
{
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
if (cache_end)
cache_end->next = cd;
cd->next = NULL;
@@ -427,7 +427,7 @@ end_link_cd(cache_desc_t *cd)
static ERTS_INLINE void
unlink_cd(cache_desc_t *cd)
{
-
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
if (cd->next)
cd->next->prev = cd->prev;
else
@@ -445,6 +445,7 @@ static ERTS_INLINE void
check_cache_limits(void)
{
cache_desc_t *cd;
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
max_cached_seg_size = 0;
min_cached_seg_size = ~((Uint) 0);
for (cd = cache; cd; cd = cd->next) {
@@ -463,7 +464,7 @@ adjust_cache_size(int force_check_limits)
int check_limits = force_check_limits;
Sint max_cached = ((Sint) segments.current.watermark
- (Sint) segments.current.no);
-
+ ERTS_LC_ASSERT(erts_lc_mtx_is_locked(&mseg_mutex));
while (((Sint) cache_size) > max_cached && ((Sint) cache_size) > 0) {
ASSERT(cache_end);
cd = cache_end;
@@ -487,9 +488,7 @@ adjust_cache_size(int force_check_limits)
static void
check_cache(void *unused)
{
-#ifdef ERTS_SMP
erts_mtx_lock(&mseg_mutex);
-#endif
is_cache_check_scheduled = 0;
@@ -502,10 +501,7 @@ check_cache(void *unused)
INC_CC(check_cache);
-#ifdef ERTS_SMP
erts_mtx_unlock(&mseg_mutex);
-#endif
-
}
static void