MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vmspace_exec

Function vmspace_exec

freebsd/vm/vm_map.c:4860–4886  ·  view source on GitHub ↗

* Unshare the specified VM space for exec. If other processes are * mapped to it, then create a new one. The new vmspace is null. */

Source from the content-addressed store, hash-verified

4858 * mapped to it, then create a new one. The new vmspace is null.
4859 */
4860int
4861vmspace_exec(struct proc *p, vm_offset_t minuser, vm_offset_t maxuser)
4862{
4863 struct vmspace *oldvmspace = p->p_vmspace;
4864 struct vmspace *newvmspace;
4865
4866 KASSERT((curthread->td_pflags & TDP_EXECVMSPC) == 0,
4867 ("vmspace_exec recursed"));
4868 newvmspace = vmspace_alloc(minuser, maxuser, pmap_pinit);
4869 if (newvmspace == NULL)
4870 return (ENOMEM);
4871 newvmspace->vm_swrss = oldvmspace->vm_swrss;
4872 /*
4873 * This code is written like this for prototype purposes. The
4874 * goal is to avoid running down the vmspace here, but let the
4875 * other process's that are still using the vmspace to finally
4876 * run it down. Even though there is little or no chance of blocking
4877 * here, it is a good idea to keep this form for future mods.
4878 */
4879 PROC_VMSPACE_LOCK(p);
4880 p->p_vmspace = newvmspace;
4881 PROC_VMSPACE_UNLOCK(p);
4882 if (p == curthread->td_proc)
4883 pmap_activate(curthread);
4884 curthread->td_pflags |= TDP_EXECVMSPC;
4885 return (0);
4886}
4887
4888/*
4889 * Unshare the specified VM space for forcing COW. This

Callers 1

exec_new_vmspaceFunction · 0.85

Calls 2

vmspace_allocFunction · 0.85
pmap_activateFunction · 0.50

Tested by

no test coverage detected