-/* When trying to get all_threads_lock one should make sure that
- * SIG_STOP_FOR_GC is not blocked. Else there would be a possible
- * deadlock: gc locks it, other thread blocks signals, gc sends stop
- * request to other thread and waits, other thread blocks on lock. */
-void check_sig_stop_for_gc_can_arrive_or_lose()
-{
- /* Get the current sigmask, by blocking the empty set. */
- sigset_t empty,current;
- sigemptyset(&empty);
- thread_sigmask(SIG_BLOCK, &empty, ¤t);
- if (sigismember(¤t,SIG_STOP_FOR_GC))
- lose("SIG_STOP_FOR_GC cannot arrive: it is blocked\n");
- if (SymbolValue(GC_INHIBIT,arch_os_get_current_thread()) != NIL)
- lose("SIG_STOP_FOR_GC cannot arrive: gc is inhibited\n");
- if (arch_pseudo_atomic_atomic(NULL))
- lose("SIG_STOP_FOR_GC cannot arrive: in pseudo atomic\n");
-}
-
-#define GET_ALL_THREADS_LOCK(name) \
- { \
- sigset_t _newset,_oldset; \
- sigemptyset(&_newset); \
- sigaddset_deferrable(&_newset); \
- thread_sigmask(SIG_BLOCK, &_newset, &_oldset); \
- check_sig_stop_for_gc_can_arrive_or_lose(); \
- FSHOW_SIGNAL((stderr,"/%s:waiting on lock=%ld, thread=%lu\n",name, \
- all_threads_lock,arch_os_get_current_thread()->os_thread)); \
- pthread_mutex_lock(&all_threads_lock); \
- FSHOW_SIGNAL((stderr,"/%s:got lock, thread=%lu\n", \
- name,arch_os_get_current_thread()->os_thread));
-
-#define RELEASE_ALL_THREADS_LOCK(name) \
- FSHOW_SIGNAL((stderr,"/%s:released lock\n",name)); \
- pthread_mutex_unlock(&all_threads_lock); \
- thread_sigmask(SIG_SETMASK,&_oldset,0); \
- }
-