mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Finalize mutex prior to sweeping
This commit is contained in:
parent
4a940918ee
commit
ac7fec70a0
2 changed files with 10 additions and 0 deletions
9
gc.c
9
gc.c
|
@ -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));
|
fprintf(stderr, "sweep is freeing unmarked obj: %p with tag %ld\n", p, type_of(p));
|
||||||
#endif
|
#endif
|
||||||
mark(p) = gc_color_blue; // Needed?
|
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
|
// free p
|
||||||
heap_freed += size;
|
heap_freed += size;
|
||||||
if (((((char *)q) + q->size) == (char *)p) && (q != h->free_list)) {
|
if (((((char *)q) + q->size) == (char *)p) && (q != h->free_list)) {
|
||||||
|
|
1
test.scm
1
test.scm
|
@ -14,6 +14,7 @@
|
||||||
(define tmp2 (make-mutex))
|
(define tmp2 (make-mutex))
|
||||||
(mutex-lock! tmp2)
|
(mutex-lock! tmp2)
|
||||||
(mutex-unlock! tmp2)
|
(mutex-unlock! tmp2)
|
||||||
|
(set! tmp2 #f)
|
||||||
|
|
||||||
;; A program to prove if cooperation is working, or if it
|
;; A program to prove if cooperation is working, or if it
|
||||||
;; is blocked by another thread. The (read) causes the main
|
;; is blocked by another thread. The (read) causes the main
|
||||||
|
|
Loading…
Add table
Reference in a new issue