Date: Wed, 14 Jul 2004 23:22:54 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 57366 for review Message-ID: <200407142322.i6ENMsog029007@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=57366 Change 57366 by peter@peter_melody on 2004/07/14 23:22:27 IFC @57365 Affected files ... .. //depot/projects/hammer/lib/libpthread/arch/alpha/include/pthread_md.h#4 integrate .. //depot/projects/hammer/lib/libpthread/arch/amd64/include/pthread_md.h#5 integrate .. //depot/projects/hammer/lib/libpthread/arch/arm/include/pthread_md.h#2 integrate .. //depot/projects/hammer/lib/libpthread/arch/i386/include/pthread_md.h#6 integrate .. //depot/projects/hammer/lib/libpthread/arch/sparc64/include/pthread_md.h#2 integrate .. //depot/projects/hammer/lib/libpthread/pthread.map#9 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_create.c#15 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_exit.c#8 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_init.c#15 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_kern.c#30 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_priority_queue.c#5 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_private.h#26 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_sig.c#21 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_spec.c#4 integrate .. //depot/projects/hammer/sbin/geom/core/geom.8#3 integrate .. //depot/projects/hammer/share/dict/freebsd#3 integrate .. //depot/projects/hammer/share/man/man4/adw.4#2 integrate .. //depot/projects/hammer/share/man/man4/amr.4#7 integrate .. //depot/projects/hammer/share/man/man4/asr.4#6 integrate .. //depot/projects/hammer/share/man/man4/ed.4#3 integrate .. //depot/projects/hammer/share/man/man4/my.4#4 integrate .. //depot/projects/hammer/sys/alpha/alpha/pmap.c#30 integrate .. //depot/projects/hammer/sys/amd64/amd64/pmap.c#92 integrate .. //depot/projects/hammer/sys/amd64/include/pmap.h#42 integrate .. //depot/projects/hammer/sys/arm/arm/pmap.c#5 integrate .. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_proto.h#20 integrate .. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_syscall.h#18 integrate .. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_syscalls.c#18 integrate .. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_sysent.c#18 integrate .. //depot/projects/hammer/sys/compat/freebsd32/syscalls.master#22 integrate .. //depot/projects/hammer/sys/dev/acpica/acpi_cmbat.c#15 integrate .. //depot/projects/hammer/sys/dev/acpica/acpi_pci.c#15 integrate .. //depot/projects/hammer/sys/dev/fdc/fdc.c#8 integrate .. //depot/projects/hammer/sys/dev/fdc/fdc_isa.c#3 integrate .. //depot/projects/hammer/sys/dev/fdc/fdc_pccard.c#3 integrate .. //depot/projects/hammer/sys/dev/snp/snp.c#11 integrate .. //depot/projects/hammer/sys/i386/i386/local_apic.c#9 integrate .. //depot/projects/hammer/sys/kern/kern_descrip.c#27 integrate .. //depot/projects/hammer/sys/kern/kern_event.c#17 integrate .. //depot/projects/hammer/sys/kern/kern_module.c#5 integrate .. //depot/projects/hammer/sys/net/if_sl.c#14 integrate .. //depot/projects/hammer/sys/net/if_var.h#20 integrate .. //depot/projects/hammer/sys/netgraph/ng_eiface.c#11 integrate .. //depot/projects/hammer/sys/netgraph/ng_fec.c#9 integrate .. //depot/projects/hammer/sys/netgraph/ng_iface.c#12 integrate .. //depot/projects/hammer/sys/netgraph/ng_ppp.c#7 integrate .. //depot/projects/hammer/sys/netgraph/ng_pppoe.c#10 integrate .. //depot/projects/hammer/sys/netgraph/ng_tty.c#6 integrate .. //depot/projects/hammer/sys/pc98/conf/NOTES#31 integrate .. //depot/projects/hammer/sys/sys/event.h#4 integrate .. //depot/projects/hammer/sys/sys/eventvar.h#2 integrate .. //depot/projects/hammer/sys/ufs/ffs/ffs_vfsops.c#25 integrate .. //depot/projects/hammer/usr.bin/sed/compile.c#3 integrate .. //depot/projects/hammer/usr.bin/sed/defs.h#2 integrate .. //depot/projects/hammer/usr.bin/sed/main.c#4 integrate .. //depot/projects/hammer/usr.bin/sed/misc.c#4 integrate .. //depot/projects/hammer/usr.bin/sed/process.c#9 integrate .. //depot/projects/hammer/usr.bin/sed/sed.1#6 integrate .. //depot/projects/hammer/usr.bin/tr/cmap.c#2 integrate .. //depot/projects/hammer/usr.bin/tr/cset.c#2 integrate .. //depot/projects/hammer/usr.bin/tr/cset.h#2 integrate .. //depot/projects/hammer/usr.sbin/ppp/radius.c#7 integrate Differences ... ==== //depot/projects/hammer/lib/libpthread/arch/alpha/include/pthread_md.h#4 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/arch/alpha/include/pthread_md.h,v 1.3 2003/09/26 06:53:54 marcel Exp $ + * $FreeBSD: src/lib/libpthread/arch/alpha/include/pthread_md.h,v 1.4 2004/07/13 22:54:22 davidxu Exp $ */ #ifndef _PTHREAD_MD_H_ @@ -218,14 +218,27 @@ static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + _tcb_set(kcb, tcb); - if (setmbox != 0) - _alpha_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _alpha_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _alpha_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _alpha_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } ==== //depot/projects/hammer/lib/libpthread/arch/amd64/include/pthread_md.h#5 (text+ko) ==== @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/arch/amd64/include/pthread_md.h,v 1.5 2003/10/23 06:12:57 peter Exp $ + * $FreeBSD: src/lib/libpthread/arch/amd64/include/pthread_md.h,v 1.6 2004/07/13 22:54:22 davidxu Exp $ */ /* * Machine-dependent thread prototypes/definitions for the thread kernel. @@ -235,17 +235,31 @@ static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext, - 0, NULL); - /* We should not reach here. */ + + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _amd64_restore_context( + &tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + /* We should not reach here. */ + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + return (-1); } #endif ==== //depot/projects/hammer/lib/libpthread/arch/arm/include/pthread_md.h#2 (text+ko) ==== @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/arch/arm/include/pthread_md.h,v 1.1 2004/05/14 12:21:29 cognet Exp $ + * $FreeBSD: src/lib/libpthread/arch/arm/include/pthread_md.h,v 1.3 2004/07/14 00:58:53 davidxu Exp $ */ /* @@ -227,15 +227,25 @@ static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } ==== //depot/projects/hammer/lib/libpthread/arch/i386/include/pthread_md.h#6 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/arch/i386/include/pthread_md.h,v 1.7 2003/09/19 23:28:13 marcel Exp $ + * $FreeBSD: src/lib/libpthread/arch/i386/include/pthread_md.h,v 1.8 2004/07/13 22:54:23 davidxu Exp $ */ /* * Machine-dependent thread prototypes/definitions for the thread kernel. @@ -237,15 +237,27 @@ static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; + if ((kcb == NULL) || (tcb == NULL)) return (-1); kcb->kcb_curtcb = tcb; - if (setmbox != 0) - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, - (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox != 0) + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, + 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } ==== //depot/projects/hammer/lib/libpthread/arch/sparc64/include/pthread_md.h#2 (text+ko) ==== @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/arch/sparc64/include/pthread_md.h,v 1.1 2003/10/09 02:32:28 deischen Exp $ + * $FreeBSD: src/lib/libpthread/arch/sparc64/include/pthread_md.h,v 1.2 2004/07/13 22:54:23 davidxu Exp $ */ /* @@ -227,15 +227,25 @@ static __inline int _thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox) { + extern int _libkse_debug; mcontext_t *mc; _tcb_set(kcb, tcb); mc = &tcb->tcb_tmbx.tm_context.uc_mcontext; - if (setmbox) - _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, - (intptr_t *)&kcb->kcb_kmbx.km_curthread); - else - _thr_setcontext(mc, 0, NULL); + if (_libkse_debug == 0) { + tcb->tcb_tmbx.tm_lwp = kcb->kcb_kmbx.km_lwp; + if (setmbox) + _thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx, + (intptr_t *)&kcb->kcb_kmbx.km_curthread); + else + _thr_setcontext(mc, 0, NULL); + } else { + if (setmbox) + kse_switchin(&tcb->tcb_tmbx, KSE_SWITCHIN_SETTMBX); + else + kse_switchin(&tcb->tcb_tmbx, 0); + } + /* We should not reach here. */ return (-1); } ==== //depot/projects/hammer/lib/libpthread/pthread.map#9 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/lib/libpthread/pthread.map,v 1.10 2004/02/10 05:36:09 deischen Exp $ +# $FreeBSD: src/lib/libpthread/pthread.map,v 1.11 2004/07/13 22:52:53 davidxu Exp $ LIBTHREAD_1_0 { global: ___creat; @@ -329,14 +329,11 @@ writev; # Debugger needs these. + _libkse_debug; + _thread_activated; _thread_list; - _thread_next_offset; - _thread_uniqueid_offset; - _thread_state_offset; - _thread_name_offset; - _thread_ctx_offset; - _thread_PS_RUNNING_value; - _thread_PS_DEAD_value; + _thread_keytable; + _thread_active_threads; local: *; ==== //depot/projects/hammer/lib/libpthread/thread/thr_create.c#15 (text+ko) ==== @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.54 2004/06/12 07:40:01 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.55 2004/07/13 22:53:56 davidxu Exp $ */ #include <errno.h> #include <stdlib.h> @@ -44,20 +44,6 @@ #include "thr_private.h" #include "libc_private.h" -#define OFF(f) offsetof(struct pthread, f) -int _thread_next_offset = OFF(tle.tqe_next); -int _thread_uniqueid_offset = OFF(uniqueid); -int _thread_state_offset = OFF(state); -int _thread_name_offset = OFF(name); -void *_thread_tcb_offset = OFF(tcb); -#undef OFF -#define OFF(f) offsetof(struct tcb, f) -int _thread_ctx_offset = OFF(tcb_tmbx.tm_context); -#undef OFF - -int _thread_PS_RUNNING_value = PS_RUNNING; -int _thread_PS_DEAD_value = PS_DEAD; - static void free_thread(struct pthread *curthread, struct pthread *thread); static int create_stack(struct pthread_attr *pattr); static void free_stack(struct pthread_attr *pattr); ==== //depot/projects/hammer/lib/libpthread/thread/thr_exit.c#8 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_exit.c,v 1.35 2003/09/14 22:52:16 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_exit.c,v 1.36 2004/07/13 22:49:58 davidxu Exp $ */ #include <errno.h> #include <unistd.h> @@ -125,11 +125,11 @@ curkse = _get_curkse(); KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock); /* Use thread_list_lock */ - _thr_active_threads--; + _thread_active_threads--; #ifdef SYSTEM_SCOPE_ONLY - if (_thr_active_threads == 0) { + if (_thread_active_threads == 0) { #else - if (_thr_active_threads == 1) { + if (_thread_active_threads == 1) { #endif KSE_LOCK_RELEASE(curkse, &_thread_list_lock); _kse_critical_leave(crit); ==== //depot/projects/hammer/lib/libpthread/thread/thr_init.c#15 (text+ko) ==== @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.62 2003/11/29 14:10:02 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.63 2004/07/13 22:51:03 davidxu Exp $ */ /* Allocate space for global thread variables here: */ @@ -310,6 +310,12 @@ _thr_signal_init(); _kse_critical_leave(&_thr_initial->tcb->tcb_tmbx); + /* + * activate threaded mode as soon as possible if we are + * being debugged + */ + if (_libkse_debug) + _kse_setthreaded(1); } /* ==== //depot/projects/hammer/lib/libpthread/thread/thr_kern.c#30 (text+ko) ==== @@ -33,10 +33,11 @@ * */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libpthread/thread/thr_kern.c,v 1.106 2004/04/08 23:16:21 deischen Exp $"); +__FBSDID("$FreeBSD: src/lib/libpthread/thread/thr_kern.c,v 1.107 2004/07/13 22:49:58 davidxu Exp $"); #include <sys/types.h> #include <sys/kse.h> +#include <sys/ptrace.h> #include <sys/signalvar.h> #include <sys/queue.h> #include <machine/atomic.h> @@ -98,7 +99,10 @@ _pq_insert_tail(&(kse)->k_schedq->sq_runq, thrd) #define KSE_RUNQ_REMOVE(kse, thrd) \ _pq_remove(&(kse)->k_schedq->sq_runq, thrd) -#define KSE_RUNQ_FIRST(kse) _pq_first(&(kse)->k_schedq->sq_runq) +#define KSE_RUNQ_FIRST(kse) \ + ((_libkse_debug == 0) ? \ + _pq_first(&(kse)->k_schedq->sq_runq) : \ + _pq_first_debug(&(kse)->k_schedq->sq_runq)) #define KSE_RUNQ_THREADS(kse) ((kse)->k_schedq->sq_runq.pq_threads) @@ -222,7 +226,7 @@ * dump core. */ sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - _thr_active_threads = 1; + _thread_active_threads = 1; /* * Enter a loop to remove and free all threads other than @@ -355,7 +359,7 @@ * dump core. */ sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - _thr_active_threads = 1; + _thread_active_threads = 1; #endif } @@ -435,6 +439,9 @@ PANIC("kse_create() failed\n"); return (-1); } + _thr_initial->tcb->tcb_tmbx.tm_lwp = + _kse_initial->k_kcb->kcb_kmbx.km_lwp; + _thread_activated = 1; #ifndef SYSTEM_SCOPE_ONLY /* Set current thread to initial thread */ @@ -630,6 +637,19 @@ if (curthread->attr.flags & PTHREAD_SCOPE_SYSTEM) kse_sched_single(&curkse->k_kcb->kcb_kmbx); else { + if (__predict_false(_libkse_debug != 0)) { + /* + * Because debugger saves single step status in thread + * mailbox's tm_dflags, we can safely clear single + * step status here. the single step status will be + * restored by kse_switchin when the thread is + * switched in again. This also lets uts run in full + * speed. + */ + ptrace(PT_CLEARSTEP, curkse->k_kcb->kcb_kmbx.km_lwp, + (caddr_t) 1, 0); + } + KSE_SET_SWITCH(curkse); _thread_enter_uts(curthread->tcb, curkse->k_kcb); } @@ -697,7 +717,7 @@ curkse->k_flags |= KF_INITIALIZED; first = 1; curthread->active = 1; - + /* Setup kernel signal masks for new thread. */ __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); /* @@ -972,7 +992,7 @@ */ if (curthread == NULL) ; /* Nothing to do here. */ - else if ((curthread->need_switchout == 0) && + else if ((curthread->need_switchout == 0) && DBG_CAN_RUN(curthread) && (curthread->blocked == 0) && (THR_IN_CRITICAL(curthread))) { /* * Resume the thread and tell it to yield when @@ -992,8 +1012,10 @@ if (ret != 0) PANIC("Can't resume thread in critical region\n"); } - else if ((curthread->flags & THR_FLAGS_IN_RUNQ) == 0) + else if ((curthread->flags & THR_FLAGS_IN_RUNQ) == 0) { + curthread->tcb->tcb_tmbx.tm_lwp = 0; kse_switchout_thread(curkse, curthread); + } curkse->k_curthread = NULL; #ifdef DEBUG_THREAD_KERN @@ -2447,7 +2469,7 @@ */ thread->uniqueid = next_uniqueid++; THR_LIST_ADD(thread); - _thr_active_threads++; + _thread_active_threads++; KSE_LOCK_RELEASE(curkse, &_thread_list_lock); _kse_critical_leave(crit); } @@ -2465,7 +2487,7 @@ curkse = _get_curkse(); KSE_LOCK_ACQUIRE(curkse, &_thread_list_lock); THR_LIST_REMOVE(thread); - _thr_active_threads--; + _thread_active_threads--; KSE_LOCK_RELEASE(curkse, &_thread_list_lock); _kse_critical_leave(crit); } @@ -2499,3 +2521,27 @@ return (NULL); } +void +_thr_debug_check_yield(struct pthread *curthread) +{ + /* + * Note that TMDF_DONOTRUNUSER is set after process is suspended. + * When we are being debugged, every suspension in process + * will cause all KSEs to schedule an upcall in kernel, unless the + * KSE is in critical region. + * If the function is being called, it means the KSE is no longer + * in critical region, if the TMDF_DONOTRUNUSER is set by debugger + * before KSE leaves critical region, we will catch it here, else + * if the flag is changed during testing, it also not a problem, + * because the change only occurs after a process suspension event + * occurs. A suspension event will always cause KSE to schedule an + * upcall, in the case, because we are not in critical region, + * upcall will be scheduled sucessfully, the flag will be checked + * again in kse_sched_multi, we won't back until the flag + * is cleared by debugger, the flag will be cleared in next + * suspension event. + */ + if ((curthread->attr.flags & PTHREAD_SCOPE_SYSTEM) == 0 && + !DBG_CAN_RUN(curthread)) + _thr_sched_switch(curthread); +} ==== //depot/projects/hammer/lib/libpthread/thread/thr_priority_queue.c#5 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_priority_queue.c,v 1.14 2003/04/28 23:56:11 deischen Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_priority_queue.c,v 1.15 2004/07/13 22:49:58 davidxu Exp $ */ #include <stdlib.h> #include <sys/queue.h> @@ -242,6 +242,57 @@ return (pthread); } +/* + * Select a thread which is allowed to run by debugger, we probably + * should merge the function into _pq_first if that function is only + * used by scheduler to select a thread. + */ +pthread_t +_pq_first_debug(pq_queue_t *pq) +{ + pq_list_t *pql, *pqlnext = NULL; + pthread_t pthread = NULL; + + /* + * Make some assertions when debugging is enabled: + */ + PQ_ASSERT_INACTIVE(pq, "_pq_first: pq_active"); + PQ_SET_ACTIVE(pq); + + for (pql = TAILQ_FIRST(&pq->pq_queue); + pql != NULL && pthread == NULL; pql = pqlnext) { + if ((pthread = TAILQ_FIRST(&pql->pl_head)) == NULL) { + /* + * The priority list is empty; remove the list + * from the queue. + */ + pqlnext = TAILQ_NEXT(pql, pl_link); + TAILQ_REMOVE(&pq->pq_queue, pql, pl_link); + + /* Mark the list as not being in the queue: */ + pql->pl_queued = 0; + } else { + /* + * note there may be a suspension event during this + * test, If TMDF_DONOTRUNUSER is set after we tested it, + * we will run the thread, this seems be a problem, + * fortunatly, when we are being debugged, all context + * switch will be done by kse_switchin, that is a + * syscall, kse_switchin will check the flag again, + * the thread will be returned via upcall, so next + * time, UTS won't run the thread. + */ + while (pthread != NULL && !DBG_CAN_RUN(pthread)) { + pthread = TAILQ_NEXT(pthread, pqe); + } + if (pthread == NULL) + pqlnext = TAILQ_NEXT(pql, pl_link); + } + } + + PQ_CLEAR_ACTIVE(pq); + return (pthread); +} static void pq_insert_prio_list(pq_queue_t *pq, int prio) ==== //depot/projects/hammer/lib/libpthread/thread/thr_private.h#26 (text+ko) ==== @@ -31,7 +31,7 @@ * * Private thread definitions for the uthread kernel. * - * $FreeBSD: src/lib/libpthread/thread/thr_private.h,v 1.114 2004/06/12 07:40:01 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_private.h,v 1.115 2004/07/13 22:49:58 davidxu Exp $ */ #ifndef _THR_PRIVATE_H @@ -430,6 +430,7 @@ int prio; int suspend; #define THR_STACK_USER 0x100 /* 0xFF reserved for <pthread.h> */ +#define THR_SIGNAL_THREAD 0x200 /* This is a signal thread */ int flags; void *arg_attr; void (*cleanup_attr) (); @@ -582,15 +583,19 @@ int seqno; }; +struct pthread_key { + volatile int allocated; + volatile int count; + int seqno; + void (*destructor) (void *); +}; #define MAX_THR_LOCKLEVEL 5 /* * Thread structure. */ struct pthread { - /* - * Thread mailbox is first so it cal be aligned properly. - */ + /* Thread control block */ struct tcb *tcb; /* @@ -816,12 +821,14 @@ #define THR_YIELD_CHECK(thrd) \ do { \ - if (((thrd)->critical_yield != 0) && \ - !(THR_IN_CRITICAL(thrd))) \ - _thr_sched_switch(thrd); \ - else if (((thrd)->check_pending != 0) && \ - !(THR_IN_CRITICAL(thrd))) \ - _thr_sig_check_pending(thrd); \ + if (!THR_IN_CRITICAL(thrd)) { \ + if (__predict_false(_libkse_debug)) \ + _thr_debug_check_yield(thrd); \ + if ((thrd)->critical_yield != 0) \ + _thr_sched_switch(thrd); \ + if ((thrd)->check_pending != 0) \ + _thr_sig_check_pending(thrd); \ + } \ } while (0) #define THR_LOCK_ACQUIRE(thrd, lck) \ @@ -882,8 +889,6 @@ _pq_insert_tail(&(thrd)->kseg->kg_schedq.sq_runq, thrd) #define THR_RUNQ_REMOVE(thrd) \ _pq_remove(&(thrd)->kseg->kg_schedq.sq_runq, thrd) -#define THR_RUNQ_FIRST(thrd) \ - _pq_first(&(thrd)->kseg->kg_schedq.sq_runq) /* * Macros to insert/remove threads to the all thread list and @@ -964,6 +969,8 @@ (((thrd)->state == PS_SUSPENDED) || \ (((thrd)->flags & THR_FLAGS_SUSPENDED) != 0)) #define THR_IS_EXITING(thrd) (((thrd)->flags & THR_FLAGS_EXITING) != 0) +#define DBG_CAN_RUN(thrd) (((thrd)->tcb->tcb_tmbx.tm_dflags & \ + TMDF_DONOTRUNUSER) == 0) extern int __isthreaded; @@ -980,6 +987,9 @@ SCLASS void *_usrstack SCLASS_PRESET(NULL); SCLASS struct kse *_kse_initial SCLASS_PRESET(NULL); SCLASS struct pthread *_thr_initial SCLASS_PRESET(NULL); +/* For debugger */ +SCLASS int _libkse_debug SCLASS_PRESET(0); +SCLASS int _thread_activated SCLASS_PRESET(0); /* List of all threads: */ SCLASS TAILQ_HEAD(, pthread) _thread_list @@ -989,7 +999,7 @@ SCLASS TAILQ_HEAD(, pthread) _thread_gc_list SCLASS_PRESET(TAILQ_HEAD_INITIALIZER(_thread_gc_list)); -SCLASS int _thr_active_threads SCLASS_PRESET(1); +SCLASS int _thread_active_threads SCLASS_PRESET(1); SCLASS TAILQ_HEAD(atfork_head, pthread_atfork) _thr_atfork_list; SCLASS pthread_mutex_t _thr_atfork_mutex; @@ -1079,6 +1089,7 @@ void _pq_insert_head(struct pq_queue *pq, struct pthread *); void _pq_insert_tail(struct pq_queue *pq, struct pthread *); struct pthread *_pq_first(struct pq_queue *pq); +struct pthread *_pq_first_debug(struct pq_queue *pq); void *_pthread_getspecific(pthread_key_t); int _pthread_key_create(pthread_key_t *, void (*) (void *)); int _pthread_key_delete(pthread_key_t); @@ -1150,6 +1161,7 @@ struct pthread *_thr_hash_find(struct pthread *); void _thr_finish_cancellation(void *arg); int _thr_sigonstack(void *sp); +void _thr_debug_check_yield(struct pthread *); /* * Aliases for _pthread functions. Should be called instead of ==== //depot/projects/hammer/lib/libpthread/thread/thr_sig.c#21 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_sig.c,v 1.78 2004/06/12 07:40:01 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_sig.c,v 1.79 2004/07/13 22:52:11 davidxu Exp $ */ #include <sys/param.h> #include <sys/types.h> @@ -232,6 +232,7 @@ pthread_sigmask(SIG_SETMASK, &sigset, &oldset); pthread_attr_init(&attr); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + attr->flags |= THR_SIGNAL_THREAD; /* sigmask will be inherited */ if (pthread_create(&_thr_sig_daemon, &attr, sig_daemon, NULL)) PANIC("can not create signal daemon thread!\n"); @@ -347,6 +348,11 @@ err_save = errno; timeout_save = curthread->timeout; intr_save = curthread->interrupted; + /* Check if the signal requires a dump of thread information: */ + if (sig == SIGINFO) { + /* Dump thread information to file: */ + _thread_dump_info(); + } _kse_critical_enter(); /* Get a fresh copy of signal mask */ __sys_sigprocmask(SIG_BLOCK, NULL, &curthread->sigmask); @@ -505,6 +511,12 @@ { _kse_critical_leave(&curthread->tcb->tcb_tmbx); + /* Check if the signal requires a dump of thread information: */ + if (shi->sig == SIGINFO) { + /* Dump thread information to file: */ + _thread_dump_info(); + } + if (((__sighandler_t *)shi->sigfunc != SIG_DFL) && ((__sighandler_t *)shi->sigfunc != SIG_IGN)) { if ((shi->sa_flags & SA_SIGINFO) != 0 || shi->info == NULL) @@ -695,12 +707,18 @@ kse_wakeup(kmbx); return (NULL); } else if (!SIGISMEMBER(pthread->sigmask, sig)) { - sigfunc = _thread_sigact[sig - 1].sa_sigaction; - if ((__sighandler_t *)sigfunc == SIG_DFL) { - if (sigprop(sig) & SA_KILL) { - kse_thr_interrupt(NULL, - KSE_INTR_SIGEXIT, sig); - /* Never reach */ + /* + * If debugger is running, we don't quick exit, + * and give it a chance to check the signal. + */ + if (_libkse_debug == 0) { + sigfunc = _thread_sigact[sig - 1].sa_sigaction; + if ((__sighandler_t *)sigfunc == SIG_DFL) { + if (sigprop(sig) & SA_KILL) { + kse_thr_interrupt(NULL, + KSE_INTR_SIGEXIT, sig); + /* Never reach */ + } } } if (pthread->state == PS_SIGSUSPEND) { @@ -1198,13 +1216,8 @@ __sys_sigprocmask(SIG_SETMASK, &sigset, &_thr_initial->sigmask); /* Enter a loop to get the existing signal status: */ for (i = 1; i <= _SIG_MAXSIG; i++) { - /* Check for signals which cannot be trapped: */ - if (i == SIGKILL || i == SIGSTOP) { - } - /* Get the signal handler details: */ - else if (__sys_sigaction(i, NULL, - &_thread_sigact[i - 1]) != 0) { + if (__sys_sigaction(i, NULL, &_thread_sigact[i - 1]) != 0) { /* * Abort this process if signal * initialisation fails: ==== //depot/projects/hammer/lib/libpthread/thread/thr_spec.c#4 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_spec.c,v 1.21 2003/08/20 02:34:14 deischen Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_spec.c,v 1.22 2004/07/13 22:49:58 davidxu Exp $ */ #include <signal.h> #include <stdlib.h> @@ -38,15 +38,8 @@ #include <pthread.h> #include "thr_private.h" -struct pthread_key { - volatile int allocated; - volatile int count; - int seqno; - void (*destructor) (); -}; - /* Static variables: */ -static struct pthread_key key_table[PTHREAD_KEYS_MAX]; +struct pthread_key _thread_keytable[PTHREAD_KEYS_MAX]; __weak_reference(_pthread_key_create, pthread_key_create); __weak_reference(_pthread_key_delete, pthread_key_delete); @@ -64,10 +57,10 @@ THR_LOCK_ACQUIRE(curthread, &_keytable_lock); for (i = 0; i < PTHREAD_KEYS_MAX; i++) { - if (key_table[i].allocated == 0) { - key_table[i].allocated = 1; - key_table[i].destructor = destructor; - key_table[i].seqno++; + if (_thread_keytable[i].allocated == 0) { + _thread_keytable[i].allocated = 1; + _thread_keytable[i].destructor = destructor; + _thread_keytable[i].seqno++; /* Unlock the key table: */ THR_LOCK_RELEASE(curthread, &_keytable_lock); @@ -91,8 +84,8 @@ /* Lock the key table: */ THR_LOCK_ACQUIRE(curthread, &_keytable_lock); - if (key_table[key].allocated) - key_table[key].allocated = 0; + if (_thread_keytable[key].allocated) + _thread_keytable[key].allocated = 0; else ret = EINVAL; @@ -123,13 +116,13 @@ (curthread->specific_data_count > 0); key++) { destructor = NULL; - if (key_table[key].allocated && + if (_thread_keytable[key].allocated && (curthread->specific[key].data != NULL)) { if (curthread->specific[key].seqno == - key_table[key].seqno) { + _thread_keytable[key].seqno) { data = (void *) curthread->specific[key].data; - destructor = key_table[key].destructor; + destructor = _thread_keytable[key].destructor; } curthread->specific[key].data = NULL; curthread->specific_data_count--; @@ -185,7 +178,7 @@ if ((pthread->specific) || (pthread->specific = pthread_key_allocate_data())) { if ((unsigned int)key < PTHREAD_KEYS_MAX) { - if (key_table[key].allocated) { + if (_thread_keytable[key].allocated) { if (pthread->specific[key].data == NULL) { if (value != NULL) pthread->specific_data_count++; @@ -193,7 +186,7 @@ pthread->specific_data_count--; pthread->specific[key].data = value; pthread->specific[key].seqno = - key_table[key].seqno; + _thread_keytable[key].seqno; ret = 0; } else ret = EINVAL; @@ -216,8 +209,8 @@ /* Check if there is specific data: */ if (pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) { /* Check if this key has been used before: */ - if (key_table[key].allocated && - (pthread->specific[key].seqno == key_table[key].seqno)) { + if (_thread_keytable[key].allocated && + (pthread->specific[key].seqno == _thread_keytable[key].seqno)) { /* Return the value: */ data = (void *) pthread->specific[key].data; } else { ==== //depot/projects/hammer/sbin/geom/core/geom.8#3 (text+ko) ==== @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/sbin/geom/core/geom.8,v 1.2 2004/07/07 21:00:57 ru Exp $ +.\" $FreeBSD: src/sbin/geom/core/geom.8,v 1.3 2004/07/14 13:32:00 pjd Exp $ .\" .Dd May 21, 2004 .Dt GEOM 8 @@ -111,6 +111,7 @@ .Sh SEE ALSO .Xr geom 4 , .Xr gconcat 8 , +.Xr glabel 8 , .Xr gnop 8 , .Xr gstripe 8 .Sh HISTORY ==== //depot/projects/hammer/share/dict/freebsd#3 (text+ko) ==== @@ -1,15 +1,30 @@ -$FreeBSD: src/share/dict/freebsd,v 1.6 2003/04/20 21:36:12 murray Exp $ +$FreeBSD: src/share/dict/freebsd,v 1.9 2004/07/14 07:10:15 murray Exp $ ABI +ACL ACPI +ADSL +AGP AMD +API +APIC +ATAPI +ATX +AVI AXP +AfterStep AlphaBIOS Appletalk +Athlon +BIBA BOFs +BOOTP BSDCon BSDi Barnes +BeOS +Bluetooth Border's +Broadcom CDROM CDROMs CDs @@ -25,11 +40,19 @@ DEVBUF DNS DTD +DVD +DVI >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407142322.i6ENMsog029007>