From: <me...@us...> - 2005-08-09 19:34:23
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20676/src/runtime Modified Files: interr.c interrupt.c interrupt.h runtime.c runtime.h thread.c Log Message: 0.9.3.34: cosmetics * move FSHOW_SIGNAL to runtime.h * print os_thread_t with %lu * recanonicalize whitespace (offenders: crhodes, jsnell, pfdietz and me (but I was handed a tainted patch by crhodes, honest)) Index: interr.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/interr.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- interr.c 2 Aug 2005 15:56:44 -0000 1.18 +++ interr.c 9 Aug 2005 13:57:51 -0000 1.19 @@ -49,7 +49,7 @@ va_list ap; fprintf(stderr, "fatal error encountered in SBCL pid %d",getpid()); #if defined(LISP_FEATURE_SB_THREAD) - fprintf(stderr, "(tid %ld)",thread_self()); + fprintf(stderr, "(tid %lu)",thread_self()); #endif if (fmt) { fprintf(stderr, ":\n"); Index: interrupt.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.c,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- interrupt.c 4 Aug 2005 12:48:20 -0000 1.82 +++ interrupt.c 9 Aug 2005 13:57:51 -0000 1.83 @@ -406,11 +406,9 @@ fake_foreign_function_call(context); } -#ifdef QSHOW_SIGNALS - FSHOW((stderr, - "/entering interrupt_handle_now(%d, info, context)\n", - signal)); -#endif + FSHOW_SIGNAL((stderr, + "/entering interrupt_handle_now(%d, info, context)\n", + signal)); if (ARE_SAME_HANDLER(handler.c, SIG_DFL)) { @@ -437,9 +435,7 @@ /* Allow signals again. */ thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); -#ifdef QSHOW_SIGNALS - SHOW("calling Lisp-level handler"); -#endif + FSHOW_SIGNAL((stderr,"/calling Lisp-level handler\n")); funcall3(handler.lisp, make_fixnum(signal), @@ -447,9 +443,7 @@ context_sap); } else { -#ifdef QSHOW_SIGNALS - SHOW("calling C-level handler"); -#endif + FSHOW_SIGNAL((stderr,"/calling C-level handler\n")); /* Allow signals again. */ thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); @@ -464,11 +458,9 @@ undo_fake_foreign_function_call(context); /* block signals again */ } -#ifdef QSHOW_SIGNALS - FSHOW((stderr, - "/returning from interrupt_handle_now(%d, info, context)\n", - signal)); -#endif + FSHOW_SIGNAL((stderr, + "/returning from interrupt_handle_now(%d, info, context)\n", + signal)); } /* This is called at the end of a critical section if the indications @@ -501,16 +493,15 @@ lose("interrupt already pending"); /* If interrupts are disabled then INTERRUPT_PENDING is set and * not PSEDUO_ATOMIC_INTERRUPTED. This is important for a pseudo - * atomic section inside a without-interrupts. + * atomic section inside a WITHOUT-INTERRUPTS. */ if (SymbolValue(INTERRUPTS_ENABLED,thread) == NIL) { store_signal_data_for_later(data,handler,signal,info,context); SetSymbolValue(INTERRUPT_PENDING, T,thread); -#ifdef QSHOW_SIGNALS - FSHOW((stderr, - "/maybe_defer_handler(%x,%d),thread=%ld: deferred\n", - (unsigned int)handler,signal,thread->os_thread)); -#endif + FSHOW_SIGNAL((stderr, + "/maybe_defer_handler(%x,%d),thread=%lu: deferred\n", + (unsigned int)handler,signal, + (unsigned long)thread->os_thread)); return 1; } /* a slightly confusing test. arch_pseudo_atomic_atomic() doesn't @@ -523,18 +514,16 @@ arch_pseudo_atomic_atomic(context)) { store_signal_data_for_later(data,handler,signal,info,context); arch_set_pseudo_atomic_interrupted(context); -#ifdef QSHOW_SIGNALS - FSHOW((stderr, - "/maybe_defer_handler(%x,%d),thread=%ld: deferred(PA)\n", - (unsigned int)handler,signal,thread->os_thread)); -#endif + FSHOW_SIGNAL((stderr, + "/maybe_defer_handler(%x,%d),thread=%lu: deferred(PA)\n", + (unsigned int)handler,signal, + (unsigned long)thread->os_thread)); return 1; } -#ifdef QSHOW_SIGNALS - FSHOW((stderr, - "/maybe_defer_handler(%x,%d),thread=%ld: not deferred\n", - (unsigned int)handler,signal,thread->os_thread)); -#endif + FSHOW_SIGNAL((stderr, + "/maybe_defer_handler(%x,%d),thread=%lu: not deferred\n", + (unsigned int)handler,signal, + (unsigned long)thread->os_thread)); return 0; } @@ -621,6 +610,7 @@ } #ifdef LISP_FEATURE_SB_THREAD + void sig_stop_for_gc_handler(int signal, siginfo_t *info, void *void_context) { @@ -835,7 +825,7 @@ { os_context_t *context = (os_context_t*)arch_os_get_context(&v_context); /* The order of interrupt execution is peculiar. If thread A - * interrupts thread B with I1, I2 and B for some reason recieves + * interrupts thread B with I1, I2 and B for some reason receives * I1 when FUN2 is already on the list, then it is FUN2 that gets * to run first. But when FUN2 is run SIG_INTERRUPT_THREAD is * enabled again and I2 hits pretty soon in FUN2 and run Index: interrupt.h =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- interrupt.h 2 Aug 2005 15:56:44 -0000 1.19 +++ interrupt.h 9 Aug 2005 13:57:51 -0000 1.20 @@ -52,7 +52,7 @@ /* signal information for pending signal. pending_signal=0 when there * is no pending signal. */ void (*pending_handler) (int, siginfo_t*, void*) ; - int pending_signal ; + int pending_signal; siginfo_t pending_info; sigset_t pending_mask; }; Index: runtime.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/runtime.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- runtime.c 14 Jul 2005 15:41:21 -0000 1.48 +++ runtime.c 9 Aug 2005 13:57:51 -0000 1.49 @@ -346,4 +346,3 @@ lose("CATS. CATS ARE NICE."); return 0; } - Index: runtime.h =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/runtime.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- runtime.h 14 Jul 2005 15:41:21 -0000 1.20 +++ runtime.h 9 Aug 2005 13:57:52 -0000 1.21 @@ -37,6 +37,12 @@ * problem.. */ #define QSHOW_SIGNALS 0 +#ifdef QSHOW_SIGNALS +#define FSHOW_SIGNAL FSHOW +#else +#define FSHOW_SIGNAL(args) +#endif + /* KLUDGE: These are in theory machine-dependent and OS-dependent, but * in practice the "foo int" definitions work for all the machines * that SBCL runs on as of 0.6.7. If we port to the Alpha or some Index: thread.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/thread.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- thread.c 2 Aug 2005 15:56:44 -0000 1.44 +++ thread.c 9 Aug 2005 13:57:52 -0000 1.45 @@ -43,19 +43,13 @@ sigemptyset(&empty); thread_sigmask(SIG_BLOCK, &empty, ¤t); if (sigismember(¤t,SIG_STOP_FOR_GC)) - lose("SIG_STOP_FOR_GC is blocked\n"); + lose("SIG_STOP_FOR_GC cannot arrive: it is blocked\n"); if (SymbolValue(INTERRUPTS_ENABLED,arch_os_get_current_thread()) == NIL) - lose("interrupts disabled\n"); + lose("SIG_STOP_FOR_GC cannot arrive: interrupts disabled\n"); if (arch_pseudo_atomic_atomic(NULL)) - lose("n pseudo atomic\n"); + lose("SIG_STOP_FOR_GC cannot arrive: in pseudo atomic\n"); } -#ifdef QSHOW_SIGNALS -#define FSHOW_SIGNAL FSHOW -#else -#define FSHOW_SIGNAL(args) -#endif - #define GET_ALL_THREADS_LOCK(name) \ { \ sigset_t _newset,_oldset; \ @@ -64,10 +58,10 @@ 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=%ld\n",name, \ + 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=%ld\n", \ + FSHOW_SIGNAL((stderr,"/%s:got lock, thread=%lu\n", \ name,arch_os_get_current_thread()->os_thread)); #define RELEASE_ALL_THREADS_LOCK(name) \ @@ -278,7 +272,7 @@ #ifndef __USE_XOPEN2K extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, - size_t __stacksize); + size_t __stacksize); #endif boolean create_os_thread(struct thread *th,os_thread_t *kid_tid) @@ -352,7 +346,7 @@ } #endif GET_ALL_THREADS_LOCK("reap_dead_thread") - FSHOW((stderr,"/reap_dead_thread: reaping %ld\n",th->os_thread)); + FSHOW((stderr,"/reap_dead_thread: reaping %lu\n",th->os_thread)); if(th->prev) th->prev->next=th->next; else all_threads=th->next; @@ -389,9 +383,10 @@ lispobj c=alloc_cons(function,NIL); int kill_status; /* interrupt_thread_handler locks this spinlock with - * interrupts blocked and it does so for the sake of - * arrange_return_to_lisp_function, so we must also block - * them. */ + * interrupts blocked (it does so for the sake of + * arrange_return_to_lisp_function), so we must also block + * them or else SIG_STOP_FOR_GC and all_threads_lock will find + * a way to deadlock. */ sigset_t newset,oldset; sigemptyset(&newset); sigaddset_blockable(&newset); @@ -422,23 +417,23 @@ void gc_stop_the_world() { struct thread *p,*th=arch_os_get_current_thread(); - FSHOW_SIGNAL((stderr,"/gc_stop_the_world:waiting on lock, thread=%ld\n", + FSHOW_SIGNAL((stderr,"/gc_stop_the_world:waiting on lock, thread=%lu\n", th->os_thread)); /* keep threads from starting while the world is stopped. */ get_spinlock(&all_threads_lock,(long)th); - FSHOW_SIGNAL((stderr,"/gc_stop_the_world:got lock, thread=%ld\n", + FSHOW_SIGNAL((stderr,"/gc_stop_the_world:got lock, thread=%lu\n", th->os_thread)); /* stop all other threads by sending them SIG_STOP_FOR_GC */ for(p=all_threads; p; p=p->next) { while(p->state==STATE_STARTING) sched_yield(); if((p!=th) && (p->state==STATE_RUNNING)) { - FSHOW_SIGNAL((stderr,"/gc_stop_the_world:sending sig_stop to %ld\n", + FSHOW_SIGNAL((stderr, "/gc_stop_the_world: suspending %lu\n", p->os_thread)); if(thread_kill(p->os_thread,SIG_STOP_FOR_GC)==-1) { /* we can't kill the thread; assume because it died * since we last checked */ p->state=STATE_DEAD; - FSHOW_SIGNAL((stderr,"/gc_stop_the_world:assuming %ld dead\n", + FSHOW_SIGNAL((stderr,"/gc_stop_the_world:assuming %lu dead\n", p->os_thread)); } } @@ -468,13 +463,15 @@ gc_assert(p->os_thread!=0); if((p!=th) && (p->state!=STATE_DEAD)) { if(p->state!=STATE_SUSPENDED) { - lose("gc_start_the_world: wrong thread state is %ld\n", + lose("gc_start_the_world: wrong thread state is %d\n", fixnum_value(p->state)); } + FSHOW_SIGNAL((stderr, "/gc_start_the_world: resuming %lu\n", + p->os_thread)); thread_kill(p->os_thread,SIG_STOP_FOR_GC); } } - /* we must wait for all threads to leave stopped state else we + /* we must wait for all threads to leave suspended state else we * risk signal accumulation and lose any meaning of * thread->state */ for(p=all_threads;p;) { |