mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
Mutex instead of critical section in gc.c
* libguile/gc.c (scm_gc_protect_object, scm_gc_unprotect_object): Use a mutex instead of a critical section. Remove dead code.
This commit is contained in:
parent
e7e7a719ba
commit
42882bbf42
1 changed files with 9 additions and 18 deletions
|
@ -496,22 +496,21 @@ scm_permanent_object (SCM obj)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static scm_i_pthread_mutex_t gc_protect_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_gc_protect_object (SCM obj)
|
scm_gc_protect_object (SCM obj)
|
||||||
{
|
{
|
||||||
SCM handle;
|
SCM handle;
|
||||||
|
|
||||||
/* This critical section barrier will be replaced by a mutex. */
|
scm_dynwind_begin (0);
|
||||||
/* njrev: Indeed; if my comment above is correct, there is the same
|
scm_dynwind_pthread_mutex_lock (&gc_protect_lock);
|
||||||
critsec/mutex inconsistency here. */
|
|
||||||
SCM_CRITICAL_SECTION_START;
|
|
||||||
|
|
||||||
handle = scm_hashq_create_handle_x (scm_protects, obj, scm_from_int (0));
|
handle = scm_hashq_create_handle_x (scm_protects, obj, scm_from_int (0));
|
||||||
SCM_SETCDR (handle, scm_sum (SCM_CDR (handle), scm_from_int (1)));
|
SCM_SETCDR (handle, scm_sum (SCM_CDR (handle), scm_from_int (1)));
|
||||||
|
|
||||||
protected_obj_count ++;
|
protected_obj_count ++;
|
||||||
|
|
||||||
SCM_CRITICAL_SECTION_END;
|
scm_dynwind_end ();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -526,18 +525,10 @@ scm_gc_unprotect_object (SCM obj)
|
||||||
{
|
{
|
||||||
SCM handle;
|
SCM handle;
|
||||||
|
|
||||||
/* This critical section barrier will be replaced by a mutex. */
|
scm_dynwind_begin (0);
|
||||||
/* njrev: and again. */
|
scm_dynwind_pthread_mutex_lock (&gc_protect_lock);
|
||||||
SCM_CRITICAL_SECTION_START;
|
|
||||||
|
|
||||||
if (scm_gc_running_p)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "scm_unprotect_object called during GC.\n");
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = scm_hashq_get_handle (scm_protects, obj);
|
handle = scm_hashq_get_handle (scm_protects, obj);
|
||||||
|
|
||||||
if (scm_is_false (handle))
|
if (scm_is_false (handle))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "scm_unprotect_object called on unprotected object\n");
|
fprintf (stderr, "scm_unprotect_object called on unprotected object\n");
|
||||||
|
@ -553,7 +544,7 @@ scm_gc_unprotect_object (SCM obj)
|
||||||
}
|
}
|
||||||
protected_obj_count --;
|
protected_obj_count --;
|
||||||
|
|
||||||
SCM_CRITICAL_SECTION_END;
|
scm_dynwind_end ();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue