Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_synch.c
Show First 20 Lines • Show All 564 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int swapin; | 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; | swapin = 0; | ||||
switch (td->td_state) { | switch (TD_GET_STATE(td)) { | ||||
case TDS_RUNNING: | case TDS_RUNNING: | ||||
case TDS_RUNQ: | case TDS_RUNQ: | ||||
break; | break; | ||||
case TDS_CAN_RUN: | case TDS_CAN_RUN: | ||||
KASSERT((td->td_flags & TDF_INMEM) != 0, | KASSERT((td->td_flags & TDF_INMEM) != 0, | ||||
("setrunnable: td %p not in mem, flags 0x%X inhibit 0x%X", | ("setrunnable: td %p not in mem, flags 0x%X inhibit 0x%X", | ||||
td, td->td_flags, td->td_inhibitors)); | td, td->td_flags, td->td_inhibitors)); | ||||
/* unlocks thread lock according to flags */ | /* unlocks thread lock according to flags */ | ||||
sched_wakeup(td, srqflags); | 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 | ||||
* arrange to swap in this process. | * arrange to swap in this process. | ||||
*/ | */ | ||||
if (td->td_inhibitors == TDI_SWAPPED && | if (td->td_inhibitors == TDI_SWAPPED && | ||||
(td->td_flags & TDF_SWAPINREQ) == 0) { | (td->td_flags & TDF_SWAPINREQ) == 0) { | ||||
td->td_flags |= TDF_SWAPINREQ; | td->td_flags |= TDF_SWAPINREQ; | ||||
swapin = 1; | swapin = 1; | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
panic("setrunnable: state 0x%x", td->td_state); | panic("setrunnable: state 0x%x", TD_GET_STATE(td)); | ||||
} | } | ||||
if ((srqflags & (SRQ_HOLD | SRQ_HOLDTD)) == 0) | if ((srqflags & (SRQ_HOLD | SRQ_HOLDTD)) == 0) | ||||
thread_unlock(td); | thread_unlock(td); | ||||
return (swapin); | return (swapin); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |