Author: jhb
Date: Fri May 21 17:15:56 2010
New Revision: 208391
URL: http://svn.freebsd.org/changeset/base/208391

Log:
  Assert that the thread passed to sched_bind() and sched_unbind() is
  curthread as those routines are only supported for curthread currently.
  
  MFC after:    1 month

Modified:
  head/sys/kern/sched_4bsd.c
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_4bsd.c
==============================================================================
--- head/sys/kern/sched_4bsd.c  Fri May 21 17:14:36 2010        (r208390)
+++ head/sys/kern/sched_4bsd.c  Fri May 21 17:15:56 2010        (r208391)
@@ -1462,9 +1462,8 @@ sched_bind(struct thread *td, int cpu)
 {
        struct td_sched *ts;
 
-       THREAD_LOCK_ASSERT(td, MA_OWNED);
-       KASSERT(TD_IS_RUNNING(td),
-           ("sched_bind: cannot bind non-running thread"));
+       THREAD_LOCK_ASSERT(td, MA_OWNED|MA_NOTRECURSED);
+       KASSERT(td == curthread, ("sched_bind: can only bind curthread"));
 
        ts = td->td_sched;
 
@@ -1482,6 +1481,7 @@ void
 sched_unbind(struct thread* td)
 {
        THREAD_LOCK_ASSERT(td, MA_OWNED);
+       KASSERT(td == curthread, ("sched_unbind: can only bind curthread"));
        td->td_flags &= ~TDF_BOUND;
 }
 

Modified: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c   Fri May 21 17:14:36 2010        (r208390)
+++ head/sys/kern/sched_ule.c   Fri May 21 17:15:56 2010        (r208391)
@@ -2427,6 +2427,7 @@ sched_bind(struct thread *td, int cpu)
        struct td_sched *ts;
 
        THREAD_LOCK_ASSERT(td, MA_OWNED|MA_NOTRECURSED);
+       KASSERT(td == curthread, ("sched_bind: can only bind curthread"));
        ts = td->td_sched;
        if (ts->ts_flags & TSF_BOUND)
                sched_unbind(td);
@@ -2448,6 +2449,7 @@ sched_unbind(struct thread *td)
        struct td_sched *ts;
 
        THREAD_LOCK_ASSERT(td, MA_OWNED);
+       KASSERT(td == curthread, ("sched_unbind: can only bind curthread"));
        ts = td->td_sched;
        if ((ts->ts_flags & TSF_BOUND) == 0)
                return;
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to