Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_synch.c
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/kdb.h> | #include <sys/kdb.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/rseq.h> | |||||
#include <sys/sched.h> | #include <sys/sched.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/sleepqueue.h> | #include <sys/sleepqueue.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | ||||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
* The machine independent parts of context switching. | * The machine independent parts of context switching. | ||||
* | * | ||||
* The thread lock is required on entry and is no longer held on return. | * The thread lock is required on entry and is no longer held on return. | ||||
*/ | */ | ||||
void | void | ||||
mi_switch(int flags) | mi_switch(int flags) | ||||
{ | { | ||||
uint64_t runtime, new_switchtime; | uint64_t runtime, new_switchtime; | ||||
struct thread *td; | struct thread *td, *td1; | ||||
td = curthread; /* XXX */ | td = curthread; /* XXX */ | ||||
THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); | THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); | ||||
KASSERT(!TD_ON_RUNQ(td), ("mi_switch: called by old code")); | KASSERT(!TD_ON_RUNQ(td), ("mi_switch: called by old code")); | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td)) | if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td)) | ||||
mtx_assert(&Giant, MA_NOTOWNED); | mtx_assert(&Giant, MA_NOTOWNED); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
sched_switch(td, flags); | sched_switch(td, flags); | ||||
CTR4(KTR_PROC, "mi_switch: new thread %ld (td_sched %p, pid %ld, %s)", | CTR4(KTR_PROC, "mi_switch: new thread %ld (td_sched %p, pid %ld, %s)", | ||||
td->td_tid, td_get_sched(td), td->td_proc->p_pid, td->td_name); | td->td_tid, td_get_sched(td), td->td_proc->p_pid, td->td_name); | ||||
/* | /* | ||||
* If the last thread was exiting, finish cleaning it up. | * If the last thread was exiting, finish cleaning it up. | ||||
*/ | */ | ||||
if ((td = PCPU_GET(deadthread))) { | if ((td1 = PCPU_GET(deadthread))) { | ||||
PCPU_SET(deadthread, NULL); | PCPU_SET(deadthread, NULL); | ||||
thread_stash(td); | thread_stash(td1); | ||||
} | } | ||||
if (td->td_rseq_abi != NULL) | |||||
ast_sched(td, TDA_RSEQ); | |||||
spinlock_exit(); | spinlock_exit(); | ||||
} | } | ||||
/* | /* | ||||
* Change thread state to be runnable, placing it on the run queue if | * Change thread state to be runnable, placing it on the run queue if | ||||
* it is in memory. If it is swapped out, return true so our caller | * it is in memory. If it is swapped out, return true so our caller | ||||
* will know to awaken the swapper. | * will know to awaken the swapper. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 149 Lines • Show Last 20 Lines |