summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-11-03 04:49:16 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-11-03 04:49:16 +0000
commit301b115d609d2595189bf67894c5e3db2fd34cb0 (patch)
treeb8ef20963382d8a5edc4b03cfb0512134beca910 /sys/kern/kern_time.c
parentc4f51b40511670f148550caa0d16bba6bd30f3fa (diff)
downloadFreeBSD-src-301b115d609d2595189bf67894c5e3db2fd34cb0.zip
FreeBSD-src-301b115d609d2595189bf67894c5e3db2fd34cb0.tar.gz
Cleanup some signal interfaces. Now the tdsignal function accepts
both proc pointer and thread pointer, if thread pointer is NULL, tdsignal automatically finds a thread, otherwise it sends signal to given thread. Add utility function psignal_event to send a realtime sigevent to a process according to the delivery requirement specified in struct sigevent.
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 7d3ac1a..b796529 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1413,46 +1413,29 @@ void
itimer_fire(struct itimer *it)
{
struct proc *p = it->it_proc;
- struct thread *td;
+ int ret;
if (it->it_sigev.sigev_notify == SIGEV_SIGNAL ||
it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
PROC_LOCK(p);
- if (KSI_ONQ(&it->it_ksi)) {
- it->it_overrun++;
- } else {
- if (it->it_sigev.sigev_notify == SIGEV_THREAD_ID) {
- /* XXX
- * This is too slow if there are many threads,
- * why the world don't have a thread hash table,
- * sigh.
+ if (!KSI_ONQ(&it->it_ksi)) {
+ ret = psignal_event(p, &it->it_sigev, &it->it_ksi);
+ if (__predict_false(ret != 0)) {
+ it->it_overrun++;
+ /*
+ * Broken userland code, thread went
+ * away, disarm the timer.
*/
- FOREACH_THREAD_IN_PROC(p, td) {
- if (td->td_tid ==
- it->it_sigev.sigev_notify_thread_id)
- break;
- }
- if (td != NULL)
- tdsignal(td, it->it_ksi.ksi_signo,
- &it->it_ksi, SIGTARGET_TD);
- else {
- /*
- * Broken userland code, thread went
- * away, disarm the timer.
- */
-#if 0
- it->it_overrun++;
-#else
+ if (ret == ESRCH) {
ITIMER_LOCK(it);
timespecclear(&it->it_time.it_value);
timespecclear(&it->it_time.it_interval);
callout_stop(&it->it_callout);
ITIMER_UNLOCK(it);
-#endif
}
- } else {
- psignal_info(p, &it->it_ksi);
}
+ } else {
+ it->it_overrun++;
}
PROC_UNLOCK(p);
}
OpenPOWER on IntegriCloud