-/* 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(INTERRUPTS_ENABLED,arch_os_get_current_thread()) == NIL)
- lose("SIG_STOP_FOR_GC cannot arrive: interrupts disabled\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_blockable(&_newset); \
- sigdelset(&_newset,SIG_STOP_FOR_GC); \
- 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)); \
- get_spinlock(&all_threads_lock,(long)arch_os_get_current_thread()); \
- 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)); \
- release_spinlock(&all_threads_lock); \
- thread_sigmask(SIG_SETMASK,&_oldset,0); \
- }