- Do not swap out a process if it is in creation. The process may have no

address space yet.

- Check whether a process is a system process prior to dereferencing
  its p_vmspace.  Aio assumes that only the curthread switches the address
  space of a system process.
This commit is contained in:
Seigo Tanimura 2002-09-09 09:05:06 +00:00
parent a0c422db00
commit b1f99ebe2b

View File

@ -675,9 +675,33 @@ int action;
* finishes, or a thread of this
* process may attempt to alter
* the map.
*
* Watch out for a process in
* creation. It may have no
* address space yet.
*
* An aio daemon switches its
* address space while running.
* Perform a quick check whether
* a process has P_SYSTEM.
*/
PROC_LOCK(p);
if ((p->p_flag & P_SYSTEM) != 0) {
PROC_UNLOCK(p);
continue;
}
mtx_lock_spin(&sched_lock);
if (p->p_state == PRS_NEW) {
mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(p);
continue;
}
vm = p->p_vmspace;
KASSERT(vm != NULL,
("swapout_procs: a process has no address space"));
++vm->vm_refcnt;
mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(p);
if (!vm_map_trylock(&vm->vm_map))
goto nextproc1;