Skip to content

Commit

Permalink
thread_may_gc and thread_may_interrupt take pseudo_atomic into consid…
Browse files Browse the repository at this point in the history
…eration
  • Loading branch information
dmitryvk committed Jul 8, 2010
1 parent 2b23ac9 commit 965ffdc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/runtime/thread.c
Expand Up @@ -883,10 +883,12 @@ int thread_may_gc()
// 1) SIG_STOP_FOR_GC is unblocked
// 2) GC_INHIBIT is NIL
// 3) INTERRUPTS_ENABLED is not-NIL
// 4) !pseudo_atomic

struct thread * self = arch_os_get_current_thread();

sigset_t ss;

pthread_sigmask(SIG_BLOCK, NULL, &ss);
if (sigismember(&ss, SIG_STOP_FOR_GC)) {
odprintf("SIG_STOP_FOR_GC is blocked");
Expand All @@ -897,6 +899,11 @@ int thread_may_gc()
odprintf("GC_INHIBIT != NIL");
return 0;
}

if (get_pseudo_atomic_atomic(self)) {
odprintf("pseudo_atomic");
return 0;
}

return 1;
}
Expand All @@ -906,6 +913,7 @@ int thread_may_interrupt()
// Thread may be interrupted if all of these are true:
// 1) SIGHUP is unblocked
// 2) INTERRUPTS_ENABLED is not-nil
// 3) !pseudo_atomic
struct thread * self = arch_os_get_current_thread();

sigset_t ss;
Expand All @@ -916,6 +924,11 @@ int thread_may_interrupt()
if (SymbolValue(INTERRUPTS_ENABLED, self) == NIL)
return 0;

if (get_pseudo_atomic_atomic(self)) {
odprintf("pseudo_atomic");
return 0;
}

return 1;
}

Expand Down

0 comments on commit 965ffdc

Please sign in to comment.