| 739 | } |
| 740 | |
| 741 | void |
| 742 | swapper(void) |
| 743 | { |
| 744 | struct proc *p; |
| 745 | |
| 746 | for (;;) { |
| 747 | sx_slock(&allproc_lock); |
| 748 | p = swapper_selector(swapper_wkilled_only()); |
| 749 | sx_sunlock(&allproc_lock); |
| 750 | |
| 751 | if (p == NULL) { |
| 752 | tsleep(&proc0, PVM, "swapin", SWAPIN_INTERVAL); |
| 753 | } else { |
| 754 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 755 | |
| 756 | /* |
| 757 | * Another process may be bringing or may have |
| 758 | * already brought this process in while we |
| 759 | * traverse all threads. Or, this process may |
| 760 | * have exited or even being swapped out |
| 761 | * again. |
| 762 | */ |
| 763 | if (p->p_state == PRS_NORMAL && (p->p_flag & (P_INMEM | |
| 764 | P_SWAPPINGOUT | P_SWAPPINGIN)) == 0) { |
| 765 | faultin(p); |
| 766 | } |
| 767 | PROC_UNLOCK(p); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | * First, if any processes have been sleeping or stopped for at least |
no test coverage detected