Finalize mutex prior to sweeping

This commit is contained in:
Justin Ethier 2016-01-03 21:59:09 -05:00
parent 4a940918ee
commit ac7fec70a0
2 changed files with 10 additions and 0 deletions

9
gc.c
View file

@ -573,6 +573,15 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr)
fprintf(stderr, "sweep is freeing unmarked obj: %p with tag %ld\n", p, type_of(p));
#endif
mark(p) = gc_color_blue; // Needed?
if (type_of(p) == mutex_tag) {
#if GC_DEBUG_VERBOSE
fprintf(stderr, "pthread_mutex_destroy from sweep\n");
#endif
if (pthread_mutex_destroy(&(((mutex)p)->lock)) != 0) {
fprintf(stderr, "Error destroying mutex\n");
exit(1);
}
}
// free p
heap_freed += size;
if (((((char *)q) + q->size) == (char *)p) && (q != h->free_list)) {

View file

@ -14,6 +14,7 @@
(define tmp2 (make-mutex))
(mutex-lock! tmp2)
(mutex-unlock! tmp2)
(set! tmp2 #f)
;; A program to prove if cooperation is working, or if it
;; is blocked by another thread. The (read) causes the main