Date: Wed, 24 Nov 2004 13:51:56 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65773 for review Message-ID: <200411241351.iAODpuRT037073@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65773 Change 65773 by davidxu@davidxu_alona on 2004/11/24 13:50:55 Add a mechanism to record which signal is for proc, but dispatched to the thread. Affected files ... .. //depot/projects/davidxu_thread/src/sys/kern/kern_sig.c#2 edit .. //depot/projects/davidxu_thread/src/sys/sys/proc.h#2 edit Differences ... ==== //depot/projects/davidxu_thread/src/sys/kern/kern_sig.c#2 (text+ko) ==== @@ -217,6 +217,7 @@ SIGSETNAND(set, td->td_sigmask); SIGSETNAND(p->p_siglist, set); SIGSETOR(td->td_siglist, set); + SIGSETOR(td->td_sigproc, set); if (SIGPENDING(td)) { mtx_lock_spin(&sched_lock); @@ -623,6 +624,29 @@ } /* + * Repost signals post to the proc but dispatched to the + * thread, it should only be called when thread is exiting. + */ +void +sigrepost(struct thread *td) +{ + int i; + sigset_t set; + + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + set = td->td_siglist; + SIGSETAND(set, td->td_sigproc); + if (SIGNOTEMPTY(set)) { + for (i = 1; i <= _SIG_MAXSIG; ++i) { + if (SIGISMEMBER(set, i)) { + SIGDELSET(td->td_siglist, i); + psignal(td->td_proc, i); + } + } + } +} + +/* * kern_sigprocmask() * * Manipulate signal mask. @@ -1503,6 +1527,7 @@ } else { PROC_LOCK(p); } + SIGDELSET(td->td_sigproc, sig); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(ps->ps_sigcatch, sig) && @@ -1763,9 +1788,13 @@ SIGADDSET(*siglist, sig); signotify(td); /* uses schedlock */ - if (siglist == &td->td_siglist && (td->td_waitset != NULL) && - action != SIG_HOLD) { - td->td_waitset = NULL; + if (siglist == &td->td_siglist) { + if (target == SIGTARGET_TD) + SIGDELSET(td->td_sigproc, sig); + else + SIGADDSET(td->td_sigproc, sig); + if ((td->td_waitset != NULL) && action != SIG_HOLD) + td->td_waitset = NULL; } /* @@ -2117,7 +2146,6 @@ stopevent(p, S_SIG, sig); mtx_lock(&ps->ps_mtx); } - /* * We should see pending but ignored signals * only if P_TRACED was on when they were posted. @@ -2142,6 +2170,7 @@ * otherwise we just look for signals again. */ SIGDELSET(td->td_siglist, sig); /* clear old signal */ + if (td->td_pflags & TDP_SA) SIGADDSET(td->td_sigmask, sig); if (newsig == 0) @@ -2160,6 +2189,7 @@ * signal is being masked, look for other signals. */ SIGADDSET(td->td_siglist, sig); + SIGDELSET(td->td_sigproc, sig); if (td->td_pflags & TDP_SA) SIGDELSET(td->td_sigmask, sig); if (SIGISMEMBER(td->td_sigmask, sig)) ==== //depot/projects/davidxu_thread/src/sys/sys/proc.h#2 (text+ko) ==== @@ -281,6 +281,7 @@ sigset_t td_oldsigmask; /* (k) Saved mask from pre sigpause. */ sigset_t td_sigmask; /* (c) Current signal mask. */ sigset_t td_siglist; /* (c) Sigs arrived, not delivered. */ + sigset_t td_sigproc; /* (c) Signals targets proc. */ sigset_t *td_waitset; /* (c) Wait set for sigwait. */ TAILQ_ENTRY(thread) td_umtx; /* (c?) Link for when we're blocked. */ volatile u_int td_generation; /* (k) For detection of preemption */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411241351.iAODpuRT037073>