Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_synch.c
Show First 20 Lines • Show All 532 Lines • ▼ Show 20 Lines | if ((td = PCPU_GET(deadthread))) { | ||||
thread_stash(td); | thread_stash(td); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* 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. | ||||
* | |||||
* Requires the thread lock on entry, drops on exit. | |||||
*/ | */ | ||||
int | int | ||||
setrunnable(struct thread *td) | setrunnable(struct thread *td, int srqflags) | ||||
{ | { | ||||
int swapin; | |||||
THREAD_LOCK_ASSERT(td, MA_OWNED); | THREAD_LOCK_ASSERT(td, MA_OWNED); | ||||
KASSERT(td->td_proc->p_state != PRS_ZOMBIE, | KASSERT(td->td_proc->p_state != PRS_ZOMBIE, | ||||
("setrunnable: pid %d is a zombie", td->td_proc->p_pid)); | ("setrunnable: pid %d is a zombie", td->td_proc->p_pid)); | ||||
swapin = 0; | |||||
switch (td->td_state) { | switch (td->td_state) { | ||||
case TDS_RUNNING: | case TDS_RUNNING: | ||||
case TDS_RUNQ: | case TDS_RUNQ: | ||||
break; | |||||
case TDS_CAN_RUN: | |||||
KASSERT((td->td_flags & TDF_INMEM) != 0, | |||||
("setrunnable: td %p not in mem, flags 0x%X inhibit 0x%X", | |||||
td, td->td_flags, td->td_inhibitors)); | |||||
/* unlocks thread lock according to flags */ | |||||
sched_wakeup(td, srqflags); | |||||
return (0); | return (0); | ||||
case TDS_INHIBITED: | case TDS_INHIBITED: | ||||
/* | /* | ||||
* If we are only inhibited because we are swapped out | * If we are only inhibited because we are swapped out | ||||
* then arange to swap in this process. Otherwise just return. | * arrange to swap in this process. | ||||
*/ | */ | ||||
if (td->td_inhibitors != TDI_SWAPPED) | if (td->td_inhibitors == TDI_SWAPPED && | ||||
return (0); | (td->td_flags & TDF_SWAPINREQ) == 0) { | ||||
/* FALLTHROUGH */ | td->td_flags |= TDF_SWAPINREQ; | ||||
case TDS_CAN_RUN: | swapin = 1; | ||||
} | |||||
break; | break; | ||||
default: | default: | ||||
printf("state is 0x%x", td->td_state); | panic("setrunnable: state 0x%x", td->td_state); | ||||
panic("setrunnable(2)"); | |||||
} | } | ||||
if ((td->td_flags & TDF_INMEM) == 0) { | if ((srqflags & (SRQ_HOLD | SRQ_HOLDTD)) == 0) | ||||
if ((td->td_flags & TDF_SWAPINREQ) == 0) { | thread_unlock(td); | ||||
td->td_flags |= TDF_SWAPINREQ; | |||||
return (1); | return (swapin); | ||||
} | |||||
} else | |||||
sched_wakeup(td); | |||||
return (0); | |||||
} | } | ||||
/* | /* | ||||
* Compute a tenex style load average of a quantity on | * Compute a tenex style load average of a quantity on | ||||
* 1, 5 and 15 minute intervals. | * 1, 5 and 15 minute intervals. | ||||
*/ | */ | ||||
static void | static void | ||||
loadav(void *arg) | loadav(void *arg) | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |