This commit is contained in:
Justin Ethier 2015-12-23 22:09:10 -05:00
parent e7e8cbd744
commit eaac66ab37
3 changed files with 16 additions and 9 deletions

13
gc.c
View file

@ -1156,7 +1156,8 @@ void gc_wait_handshake()
}
thread_status = ATOMIC_GET(&(m->thread_state));
if (thread_status == CYC_THREAD_STATE_BLOCKED) {
if (thread_status == CYC_THREAD_STATE_BLOCKED ||
thread_status == CYC_THREAD_STATE_BLOCKED_COOPERATING) {
if (statusm == STATUS_ASYNC) { // Prev state
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);
// Async is done, so clean up old mark data from the last collection
@ -1173,12 +1174,10 @@ printf("DEBUG - is mutator still blocked?\n");
if (ATOMIC_SET_IF_EQ(&(m->thread_state),
CYC_THREAD_STATE_BLOCKED,
CYC_THREAD_STATE_BLOCKED_COOPERATING)
// TODO: seems to work OK for first collection, but then gc is blocked
// again. tried this but there must be another issue...
// ||
// ATOMIC_SET_IF_EQ(&(m->thread_state),
// CYC_THREAD_STATE_BLOCKED_COOPERATING,
// CYC_THREAD_STATE_BLOCKED_COOPERATING)
||
ATOMIC_SET_IF_EQ(&(m->thread_state),
CYC_THREAD_STATE_BLOCKED_COOPERATING,
CYC_THREAD_STATE_BLOCKED_COOPERATING)
) {
printf("DEBUG - update mutator GC status\n");
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);

View file

@ -2157,10 +2157,17 @@ void gc_mark_globals()
char *gc_fixup_moved_obj(gc_thread_data *thd, int *alloci, char *obj, object hp)
{
int acquired_lock = 0;
if (grayed(obj)) {
pthread_mutex_lock(&(thd->lock));
// Try to acquire the lock, because we are already locked if
// the collector is cooperating on behalf of the mutator
if (pthread_mutex_trylock(&(thd->lock)) == 0) {
acquired_lock = 1;
}
gc_mark_gray2(thd, hp);
pthread_mutex_unlock(&(thd->lock));
if (acquired_lock){
pthread_mutex_unlock(&(thd->lock));
}
}
// hp ==> new heap object, point to it from old stack object

View file

@ -32,6 +32,7 @@
(loop))
)))
(read)
(write "main thread is done")
;;;; A temporary file to attempt to repro crashing / data corruption
;;(import (scheme base) (scheme write))