- pages that points to page directory values of all processes,
shared with the kernel, mapped into kernel address space; kernel is notified of its location. kernel segment size is increased to make it fit. - map in kernel and other processes that don't have their own page table using single 4MB (global) mapping. - new sanity check facility: objects that are allocated with the slab allocator are, when running with sanity checking on, marked readonly until they are explicitly unlocked using the USE() macro. - another sanity check facility: collect all uses of memory and see if they don't overlap with (a) eachother and (b) free memory - own munmap() and munmap_text() functions. - exec() recovers from out-of-memory conditions properly now; this solves some weird exec() behaviour - chew off memory from the same side of the chunk as where we start scanning, solving some memory fragmentation issues - use avl trees for freelist and phys_ranges in regions - implement most useful part of munmap() - remap() stuff is GQ's for shared memory
This commit is contained in:
+33
-1
@@ -13,7 +13,10 @@
|
||||
#include <minix/ipc.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <minix/debug.h>
|
||||
#include <minix/bitmap.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <env.h>
|
||||
|
||||
@@ -31,6 +34,8 @@ PUBLIC int do_fork(message *msg)
|
||||
{
|
||||
int r, proc, s, childproc, fullvm;
|
||||
struct vmproc *vmp, *vmc;
|
||||
pt_t origpt;
|
||||
vir_bytes msgaddr;
|
||||
|
||||
SANITYCHECK(SCL_FUNCTIONS);
|
||||
|
||||
@@ -49,6 +54,9 @@ PUBLIC int do_fork(message *msg)
|
||||
|
||||
vmp = &vmproc[proc]; /* parent */
|
||||
vmc = &vmproc[childproc]; /* child */
|
||||
vm_assert(vmc->vm_slot == childproc);
|
||||
|
||||
NOTRUNNABLE(vmp->vm_endpoint);
|
||||
|
||||
if(vmp->vm_flags & VMF_HAS_DMA) {
|
||||
printf("VM: %d has DMA memory and may not fork\n", msg->VMF_ENDPOINT);
|
||||
@@ -58,14 +66,20 @@ PUBLIC int do_fork(message *msg)
|
||||
fullvm = vmp->vm_flags & VMF_HASPT;
|
||||
|
||||
/* The child is basically a copy of the parent. */
|
||||
origpt = vmc->vm_pt;
|
||||
*vmc = *vmp;
|
||||
vmc->vm_slot = childproc;
|
||||
vmc->vm_regions = NULL;
|
||||
vmc->vm_endpoint = NONE; /* In case someone tries to use it. */
|
||||
vmc->vm_pt = origpt;
|
||||
vmc->vm_flags &= ~VMF_HASPT;
|
||||
|
||||
#if VMSTATS
|
||||
vmc->vm_bytecopies = 0;
|
||||
#endif
|
||||
|
||||
SANITYCHECK(SCL_DETAIL);
|
||||
|
||||
if(fullvm) {
|
||||
SANITYCHECK(SCL_DETAIL);
|
||||
|
||||
@@ -74,6 +88,8 @@ PUBLIC int do_fork(message *msg)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
vmc->vm_flags |= VMF_HASPT;
|
||||
|
||||
SANITYCHECK(SCL_DETAIL);
|
||||
|
||||
if(map_proc_copy(vmc, vmp) != OK) {
|
||||
@@ -108,6 +124,7 @@ PUBLIC int do_fork(message *msg)
|
||||
/* Create a copy of the parent's core image for the child. */
|
||||
child_abs = (phys_bytes) child_base << CLICK_SHIFT;
|
||||
parent_abs = (phys_bytes) vmp->vm_arch.vm_seg[D].mem_phys << CLICK_SHIFT;
|
||||
FIXME("VM uses kernel for abscopy");
|
||||
s = sys_abscopy(parent_abs, child_abs, prog_bytes);
|
||||
if (s < 0) vm_panic("do_fork can't copy", s);
|
||||
|
||||
@@ -124,14 +141,29 @@ PUBLIC int do_fork(message *msg)
|
||||
/* Only inherit these flags. */
|
||||
vmc->vm_flags &= (VMF_INUSE|VMF_SEPARATE|VMF_HASPT);
|
||||
|
||||
/* inherit the priv call bitmaps */
|
||||
memcpy(&vmc->vm_call_priv_mask, &vmp->vm_call_priv_mask,
|
||||
sizeof(vmc->vm_call_priv_mask));
|
||||
|
||||
/* Tell kernel about the (now successful) FORK. */
|
||||
if((r=sys_fork(vmp->vm_endpoint, childproc,
|
||||
&vmc->vm_endpoint, vmc->vm_arch.vm_seg,
|
||||
fullvm ? PFF_VMINHIBIT : 0)) != OK) {
|
||||
fullvm ? PFF_VMINHIBIT : 0, &msgaddr)) != OK) {
|
||||
vm_panic("do_fork can't sys_fork", r);
|
||||
}
|
||||
|
||||
NOTRUNNABLE(vmp->vm_endpoint);
|
||||
NOTRUNNABLE(vmc->vm_endpoint);
|
||||
|
||||
if(fullvm) {
|
||||
vir_bytes vir;
|
||||
/* making these messages writable is an optimisation
|
||||
* and its return value needn't be checked.
|
||||
*/
|
||||
vir = arch_vir2map(vmc, msgaddr);
|
||||
handle_memory(vmc, vir, sizeof(message), 1);
|
||||
vir = arch_vir2map(vmp, msgaddr);
|
||||
handle_memory(vmp, vir, sizeof(message), 1);
|
||||
if((r=pt_bind(&vmc->vm_pt, vmc)) != OK)
|
||||
vm_panic("fork can't pt_bind", r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user