From d25301c8586567f23a4a1420292fec042e6496e1 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 27 Feb 2004 18:52:44 +0000 Subject: Switch the sleep/wakeup and condition variable implementations to use the sleep queue interface: - Sleep queues attempt to merge some of the benefits of both sleep queues and condition variables. Having sleep qeueus in a hash table avoids having to allocate a queue head for each wait channel. Thus, struct cv has shrunk down to just a single char * pointer now. However, the hash table does not hold threads directly, but queue heads. This means that once you have located a queue in the hash bucket, you no longer have to walk the rest of the hash chain looking for threads. Instead, you have a list of all the threads sleeping on that wait channel. - Outside of the sleepq code and the sleep/cv code the kernel no longer differentiates between cv's and sleep/wakeup. For example, calls to abortsleep() and cv_abort() are replaced with a call to sleepq_abort(). Thus, the TDF_CVWAITQ flag is removed. Also, calls to unsleep() and cv_waitq_remove() have been replaced with calls to sleepq_remove(). - The sched_sleep() function no longer accepts a priority argument as sleep's no longer inherently bump the priority. Instead, this is soley a propery of msleep() which explicitly calls sched_prio() before blocking. - The TDF_ONSLEEPQ flag has been dropped as it was never used. The associated TDF_SET_ONSLEEPQ and TDF_CLR_ON_SLEEPQ macros have also been dropped and replaced with a single explicit clearing of td_wchan. TD_SET_ONSLEEPQ() would really have only made sense if it had taken the wait channel and message as arguments anyway. Now that that only happens in one place, a macro would be overkill. --- sys/kern/kern_sig.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'sys/kern/kern_sig.c') diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index aa1e19d..c672290 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1869,12 +1870,8 @@ do_tdsignal(struct thread *td, int sig, sigtarget_t target) * It may run a bit until it hits a thread_suspend_check(). */ mtx_lock_spin(&sched_lock); - if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR)) { - if (td->td_flags & TDF_CVWAITQ) - cv_abort(td); - else - abortsleep(td); - } + if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR)) + sleepq_abort(td); mtx_unlock_spin(&sched_lock); goto out; /* @@ -1969,9 +1966,8 @@ tdsigwakeup(struct thread *td, int sig, sig_t action) * be noticed when the process returns through * trap() or syscall(). */ - if ((td->td_flags & TDF_SINTR) == 0) { + if ((td->td_flags & TDF_SINTR) == 0) return; - } /* * Process is sleeping and traced. Make it runnable * so it can discover the signal in issignal() and stop @@ -1999,14 +1995,10 @@ tdsigwakeup(struct thread *td, int sig, sig_t action) /* * Raise priority to at least PUSER. */ - if (td->td_priority > PUSER) { + if (td->td_priority > PUSER) td->td_priority = PUSER; - } } - if (td->td_flags & TDF_CVWAITQ) - cv_abort(td); - else - abortsleep(td); + sleepq_abort(td); } #ifdef SMP else { @@ -2015,9 +2007,8 @@ tdsigwakeup(struct thread *td, int sig, sig_t action) * other than kicking ourselves if we are running. * It will either never be noticed, or noticed very soon. */ - if (TD_IS_RUNNING(td) && td != curthread) { + if (TD_IS_RUNNING(td) && td != curthread) forward_signal(td); - } } #endif } -- cgit v1.1