Made g_profile_mutex a GMutex* instead of G_LOCK_DEFINE_STATIC to avoid

2001-01-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* gmem.c: Made g_profile_mutex a GMutex* instead of
	G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
	without native static mutexes. Contruct g_profile_mutex in
	g_mem_init().
This commit is contained in:
Sebastian Wilhelmi 2001-01-09 13:47:12 +00:00 committed by Sebastian Wilhelmi
parent 05122f2861
commit 9e46ef9465
10 changed files with 72 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -1,3 +1,10 @@
2001-01-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gmem.c: Made g_profile_mutex a GMutex* instead of
G_LOCK_DEFINE_STATIC to avoid deadlock for thread implementations
without native static mutexes. Contruct g_profile_mutex in
g_mem_init().
2001-01-06 Tor Lillqvist <tml@iki.fi> 2001-01-06 Tor Lillqvist <tml@iki.fi>
* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using

View File

@ -266,7 +266,7 @@ static gulong profile_mc_allocs = 0;
static gulong profile_zinit = 0; static gulong profile_zinit = 0;
static gulong profile_frees = 0; static gulong profile_frees = 0;
static gulong profile_mc_frees = 0; static gulong profile_mc_frees = 0;
G_LOCK_DEFINE_STATIC (g_profile_mutex); static GMutex *g_profile_mutex = NULL;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
static volatile gulong glib_trap_free_size = 0; static volatile gulong glib_trap_free_size = 0;
static volatile gulong glib_trap_realloc_size = 0; static volatile gulong glib_trap_realloc_size = 0;
@ -280,13 +280,13 @@ profiler_log (ProfilerJob job,
gulong n_bytes, gulong n_bytes,
gboolean success) gboolean success)
{ {
G_LOCK (g_profile_mutex); g_mutex_lock (g_profile_mutex);
if (!profile_data) if (!profile_data)
{ {
profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
if (!profile_data) /* memory system kiddin' me, eh? */ if (!profile_data) /* memory system kiddin' me, eh? */
{ {
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
return; return;
} }
} }
@ -320,7 +320,7 @@ profiler_log (ProfilerJob job,
else else
profile_mc_frees += n_bytes; profile_mc_frees += n_bytes;
} }
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
} }
static void static void
@ -369,11 +369,11 @@ g_mem_profile (void)
gulong local_mc_allocs = profile_mc_allocs; gulong local_mc_allocs = profile_mc_allocs;
gulong local_mc_frees = profile_mc_frees; gulong local_mc_frees = profile_mc_frees;
G_LOCK (g_profile_mutex); g_mutex_lock (g_profile_mutex);
if (!profile_data) if (!profile_data)
{ {
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
return; return;
} }
@ -395,7 +395,7 @@ g_mem_profile (void)
local_mc_frees, local_mc_frees,
((gdouble) local_mc_frees) / local_mc_allocs * 100.0, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0,
local_mc_allocs - local_mc_frees); local_mc_allocs - local_mc_frees);
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
} }
static gpointer static gpointer
@ -1250,5 +1250,6 @@ g_mem_init (void)
#endif #endif
#ifndef G_DISABLE_CHECKS #ifndef G_DISABLE_CHECKS
mem_chunk_recursion = g_private_new (NULL); mem_chunk_recursion = g_private_new (NULL);
g_profile_mutex = g_mutex_new ();
#endif #endif
} }

15
gmem.c
View File

@ -266,7 +266,7 @@ static gulong profile_mc_allocs = 0;
static gulong profile_zinit = 0; static gulong profile_zinit = 0;
static gulong profile_frees = 0; static gulong profile_frees = 0;
static gulong profile_mc_frees = 0; static gulong profile_mc_frees = 0;
G_LOCK_DEFINE_STATIC (g_profile_mutex); static GMutex *g_profile_mutex = NULL;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
static volatile gulong glib_trap_free_size = 0; static volatile gulong glib_trap_free_size = 0;
static volatile gulong glib_trap_realloc_size = 0; static volatile gulong glib_trap_realloc_size = 0;
@ -280,13 +280,13 @@ profiler_log (ProfilerJob job,
gulong n_bytes, gulong n_bytes,
gboolean success) gboolean success)
{ {
G_LOCK (g_profile_mutex); g_mutex_lock (g_profile_mutex);
if (!profile_data) if (!profile_data)
{ {
profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
if (!profile_data) /* memory system kiddin' me, eh? */ if (!profile_data) /* memory system kiddin' me, eh? */
{ {
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
return; return;
} }
} }
@ -320,7 +320,7 @@ profiler_log (ProfilerJob job,
else else
profile_mc_frees += n_bytes; profile_mc_frees += n_bytes;
} }
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
} }
static void static void
@ -369,11 +369,11 @@ g_mem_profile (void)
gulong local_mc_allocs = profile_mc_allocs; gulong local_mc_allocs = profile_mc_allocs;
gulong local_mc_frees = profile_mc_frees; gulong local_mc_frees = profile_mc_frees;
G_LOCK (g_profile_mutex); g_mutex_lock (g_profile_mutex);
if (!profile_data) if (!profile_data)
{ {
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
return; return;
} }
@ -395,7 +395,7 @@ g_mem_profile (void)
local_mc_frees, local_mc_frees,
((gdouble) local_mc_frees) / local_mc_allocs * 100.0, ((gdouble) local_mc_frees) / local_mc_allocs * 100.0,
local_mc_allocs - local_mc_frees); local_mc_allocs - local_mc_frees);
G_UNLOCK (g_profile_mutex); g_mutex_unlock (g_profile_mutex);
} }
static gpointer static gpointer
@ -1250,5 +1250,6 @@ g_mem_init (void)
#endif #endif
#ifndef G_DISABLE_CHECKS #ifndef G_DISABLE_CHECKS
mem_chunk_recursion = g_private_new (NULL); mem_chunk_recursion = g_private_new (NULL);
g_profile_mutex = g_mutex_new ();
#endif #endif
} }