* Bind a thread to a target cpu. */
| 2710 | * Bind a thread to a target cpu. |
| 2711 | */ |
| 2712 | void |
| 2713 | sched_bind(struct thread *td, int cpu) |
| 2714 | { |
| 2715 | struct td_sched *ts; |
| 2716 | |
| 2717 | THREAD_LOCK_ASSERT(td, MA_OWNED|MA_NOTRECURSED); |
| 2718 | KASSERT(td == curthread, ("sched_bind: can only bind curthread")); |
| 2719 | ts = td_get_sched(td); |
| 2720 | if (ts->ts_flags & TSF_BOUND) |
| 2721 | sched_unbind(td); |
| 2722 | KASSERT(THREAD_CAN_MIGRATE(td), ("%p must be migratable", td)); |
| 2723 | ts->ts_flags |= TSF_BOUND; |
| 2724 | sched_pin(); |
| 2725 | if (PCPU_GET(cpuid) == cpu) |
| 2726 | return; |
| 2727 | ts->ts_cpu = cpu; |
| 2728 | /* When we return from mi_switch we'll be on the correct cpu. */ |
| 2729 | mi_switch(SW_VOL); |
| 2730 | thread_lock(td); |
| 2731 | } |
| 2732 | |
| 2733 | /* |
| 2734 | * Release a bound thread. |
no test coverage detected