X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/d1b1c8d9119229dbeed06cd252917e54a1cb77f6..bffa3430fbbaaad29bec0b5bee9c1f0bfc7fd068:/lunaix-os/kernel/process/fork.c?ds=sidebyside diff --git a/lunaix-os/kernel/process/fork.c b/lunaix-os/kernel/process/fork.c index 6dbe737..9f257aa 100644 --- a/lunaix-os/kernel/process/fork.c +++ b/lunaix-os/kernel/process/fork.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -62,12 +63,12 @@ __dup_kernel_stack(struct thread* thread, ptr_t vm_mnt) struct leaflet* leaflet; ptr_t kstack_pn = pfn(current_thread->kstack); - kstack_pn -= pfn(KSTACK_SIZE) - 1; + kstack_pn -= pfn(KSTACK_SIZE); // copy the kernel stack pte_t* src_ptep = mkptep_pn(VMS_SELF, kstack_pn); pte_t* dest_ptep = mkptep_pn(vm_mnt, kstack_pn); - for (size_t i = 0; i < pfn(KSTACK_SIZE); i++) { + for (size_t i = 0; i <= pfn(KSTACK_SIZE); i++) { pte_t p = *src_ptep; if (pte_isguardian(p)) { @@ -149,9 +150,8 @@ done: pid_t dup_proc() { - // FIXME need investigate: issue with fork, as well as pthread - // especially when involving frequent alloc and dealloc ops - // (could be issue in allocator's segregated free list) + no_preemption(); + struct proc_info* pcb = alloc_process(); if (!pcb) { syscall_result(ENOMEM);