这篇教程C++ sys_env_set_status函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sys_env_set_status函数的典型用法代码示例。如果您正苦于以下问题:C++ sys_env_set_status函数的具体用法?C++ sys_env_set_status怎么用?C++ sys_env_set_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sys_env_set_status函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. set_pgfault_handler(pgfault); int r, childid; childid = sys_exofork(); if (childid <0) panic("exofork error in fork()!/n"); else if (childid ==0) { thisenv = &envs[ENVX(sys_getenvid())]; return 0; } else { int addr; for (addr = UTEXT; addr<UXSTACKTOP-PGSIZE; addr+=PGSIZE) { int pn = PGNUM(addr); if (((uvpd[PDX(addr)] & PTE_P) >0) && ((uvpt[pn] & PTE_P) >0) && ((uvpt[pn] & PTE_U) > 0)) duppage(childid, pn); } extern void _pgfault_upcall(); sys_page_alloc(childid, (void*) (UXSTACKTOP - PGSIZE), PTE_U|PTE_W|PTE_P); sys_env_set_pgfault_upcall(childid, _pgfault_upcall); sys_env_set_status(childid, ENV_RUNNABLE); return childid; }}
开发者ID:DoraXingyu,项目名称:JosLab_2015,代码行数:47,
示例2: sys_exofork// Allocate a new environment.// Returns envid of new environment, or < 0 on error. Errors are:// -E_NO_FREE_ENV if no free environment is available.// -E_NO_MEM on memory exhaustion.static envid_tsys_exofork(void){ // Create the new environment with env_alloc(), from kern/env.c. // It should be left as env_alloc created it, except that // status is set to ENV_NOT_RUNNABLE, and the register set is copied // from the current environment -- but tweaked so sys_exofork // will appear to return 0. // LAB 4: Your code here. //cprintf("In sysexofork/n"); struct Env* cur_env; int status = envid2env(0, &cur_env, 1); if(status < 0) return status; struct Env* new_env; status = env_alloc(&new_env, cur_env -> env_id); if(status < 0) return status; if((status = sys_env_set_status(new_env -> env_id, ENV_NOT_RUNNABLE)) < 0) return status; // Copy registers // Change return value to 0. Stored in the EAX register (new_env -> env_tf) = (cur_env -> env_tf); (new_env -> env_tf).tf_regs.reg_eax = 0; //cprintf("Out sysexofork %x/n", new_env -> env_id); return new_env -> env_id; //panic("sys_exofork not implemented");}
开发者ID:reddragon,项目名称:cse506,代码行数:34,
示例3: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. //panic("fork not implemented"); void *addr; set_pgfault_handler(pgfault); envid_t forkid = sys_exofork(); if (forkid < 0) panic("sys_exofork: %e", forkid); if(forkid == 0) { thisenv = &envs[ENVX(sys_getenvid())]; return 0; } for (addr = (uint8_t*) UTEXT; addr < (void *) USTACKTOP; addr += PGSIZE) if( (uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) ) duppage(forkid, PGNUM(addr)); if (sys_page_alloc(forkid, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_W|PTE_P) < 0) panic("user stack alloc failure/n"); extern void _pgfault_upcall(); if(sys_env_set_pgfault_upcall(forkid, _pgfault_upcall) < 0) panic("set pgfault upcall fails %d/n", forkid); if(sys_env_set_status(forkid, ENV_RUNNABLE) < 0) panic("set %d runnable fails/n", forkid); return forkid;}
开发者ID:liuxu1005,项目名称:Operating-System-Engineering,代码行数:42,
示例4: umainvoidumain(int argc, char **argv) { int ret; envid_t guest; if ((ret = sys_env_mkguest( GUEST_MEM_SZ, JOS_ENTRY )) < 0) { cprintf("Error creating a guest OS env: %e/n", ret ); exit(); } guest = ret; // Copy the guest kernel code into guest phys mem. if((ret = copy_guest_kern_gpa(guest, GUEST_KERN)) < 0) { cprintf("Error copying page into the guest - %d/n.", ret); exit(); } // Now copy the bootloader. int fd; if ((fd = open( GUEST_BOOT, O_RDONLY)) < 0 ) { cprintf("open %s for read: %e/n", GUEST_BOOT, fd ); exit(); } // sizeof(bootloader) < 512. if ((ret = map_in_guest(guest, JOS_ENTRY, 512, fd, 512, 0)) < 0) { cprintf("Error mapping bootloader into the guest - %d/n.", ret); exit(); } // Mark the guest as runnable. sys_env_set_status(guest, ENV_RUNNABLE); wait(guest);}
开发者ID:HarounH,项目名称:COL331_HardwareVirtualization,代码行数:34,
示例5: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. set_pgfault_handler (pgfault); envid_t envid; uint32_t addr; int r; envid = sys_exofork(); if (envid < 0) panic("sys_exofork: %e", envid); // We’re the child if (envid == 0) { env = &envs[ENVX(sys_getenvid())]; return 0; } // We’re the parent. for (addr = UTEXT; addr < UXSTACKTOP - PGSIZE; addr += PGSIZE) { if ((vpd[VPD(addr)] & PTE_P) > 0 && (vpt[VPN(addr)] & PTE_P) > 0 && (vpt[ VPN(addr)] & PTE_U) > 0) duppage (envid, VPN(addr)); } if ((r = sys_page_alloc (envid, (void *)(UXSTACKTOP - PGSIZE), PTE_U|PTE_W|PTE_P)) < 0) panic ("fork: page allocation failed : %e", r); extern void _pgfault_upcall (void); sys_env_set_pgfault_upcall (envid, _pgfault_upcall); // Start the child environment running if ((r = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) panic("fork: set child env status failed : %e", r); return envid; //panic("fork not implemented");}
开发者ID:zbh24,项目名称:JosLab,代码行数:49,
示例6: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ extern void _pgfault_upcall(); // LAB 4: Your code here. set_pgfault_handler(pgfault); envid_t envid = sys_exofork(); if (envid == 0) { thisenv = &envs[ENVX(sys_getenvid())]; return 0; } if (envid < 0) { panic("sys_exofork failed: %e", envid); } uint32_t addr; for (addr = 0; addr < USTACKTOP; addr += PGSIZE) { if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_U)) { duppage(envid, PGNUM(addr)); } } int alloc_err = sys_page_alloc(envid, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_W|PTE_P); if (alloc_err) { panic("sys_page_alloc failed with error: %e", alloc_err); } sys_env_set_pgfault_upcall(envid, _pgfault_upcall); int set_status_err = sys_env_set_status(envid, ENV_RUNNABLE); if (set_status_err) { panic("sys_env_set_status"); } return envid;}
开发者ID:hvpeteet,项目名称:BackupGatech,代码行数:49,
示例7: syscall// Dispatches to the correct kernel function, passing the arguments.int64_tsyscall(uint64_t syscallno, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here.// panic("syscall not implemented"); switch (syscallno) { case SYS_cputs: sys_cputs((const char *)a1, (size_t)a2); return 0; case SYS_cgetc: return sys_cgetc(); case SYS_getenvid: return sys_getenvid(); case SYS_env_destroy: return sys_env_destroy(a1); case SYS_yield: sys_yield(); return 0; case SYS_page_alloc: return sys_page_alloc((envid_t)a1, (void *)a2,(int)a3); case SYS_page_map: return sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, (int)a5); case SYS_page_unmap: return sys_page_unmap((envid_t)a1, (void *)a2); case SYS_exofork: return sys_exofork(); case SYS_env_set_status: return sys_env_set_status((envid_t)a1, a2); case SYS_env_set_pgfault_upcall: return sys_env_set_pgfault_upcall((envid_t)a1,(void *)a2); case SYS_ipc_try_send: return sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void *)a3, a4); case SYS_ipc_recv: return sys_ipc_recv((void *)a1); case SYS_env_set_trapframe: return sys_env_set_trapframe((envid_t)a1, (struct Trapframe *)a2); case SYS_time_msec: return sys_time_msec(); case SYS_packet_transmit: return sys_packet_transmit((char*)a1,(size_t)a2); case SYS_packet_receive: return sys_packet_receive((char *)a1); //lab 7 code from here case SYS_insmod: return sys_insmod((char *)a1, (char *)a2,(char *)a3); case SYS_rmmod: return sys_rmmod((char *)a1); case SYS_lsmod: return sys_lsmod(); case SYS_depmod: return sys_depmod((char *)a1); //lab7 code ends here default: return -E_NO_SYS; }}
开发者ID:deepakkumar-b,项目名称:JOS-Labs_Project,代码行数:61,
示例8: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. // // TBD: gain 10+ percent of performance improvement // by using goto-label-array. switch(syscallno) { case SYS_cputs: sys_cputs((char *) a1, (size_t) a2); break; case SYS_cgetc: return sys_cgetc(); case SYS_getenvid: return sys_getenvid(); case SYS_env_destroy: sys_env_destroy(a1); break; case SYS_exofork: return sys_exofork(); case SYS_env_set_status: return sys_env_set_status(a1, a2); default: cprintf("Error syscall(%u)/n", syscallno); panic("syscall not implemented"); return -E_INVAL; } return 0;}
开发者ID:a19990200130067,项目名称:JOS-pi,代码行数:32,
示例9: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use vpd, vpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.// envid_tfork(void){ // LAB 4: Your code here. envid_t envid; uint64_t addr; uint32_t err; extern unsigned char end[]; int r; set_pgfault_handler(pgfault); envid = sys_exofork(); if (envid < 0) panic("sys_exofork: %e", envid); if (envid == 0) { // We're the child. // The copied value of the global variable 'thisenv' // is no longer valid (it refers to the parent!). // Fix it and return 0. thisenv = &envs[ENVX(sys_getenvid())]; return 0; } //Allocate exception stack for the child if ((err = sys_page_alloc(envid, (void *) (UXSTACKTOP - PGSIZE), PTE_P|PTE_U|PTE_W)) < 0) panic("Error in sys_page_alloc: %e", err); // We're the parent. // Map our entire address space into the child. for (addr = UTEXT; addr < USTACKTOP-PGSIZE; addr += PGSIZE) { if((vpml4e[VPML4E(addr)] & PTE_P) && (vpde[VPDPE(addr)] & PTE_P) && (vpd[VPD(addr)] & PTE_P) && (vpt[VPN(addr)] & PTE_P)) { duppage(envid, VPN(addr)); } } //Allocate a new stack for the child and copy the contents of parent on to it. addr = USTACKTOP-PGSIZE; if ((r = sys_page_alloc(0, (void *)PFTEMP, PTE_P|PTE_U|PTE_W)) < 0) panic("sys_page_alloc failed: %e/n", r); memcpy(PFTEMP, (void *) ROUNDDOWN(addr, PGSIZE), PGSIZE); void *vaTemp = (void *) ROUNDDOWN(addr, PGSIZE); if ((r = sys_page_map(0, (void *)PFTEMP, envid, vaTemp, PTE_P|PTE_U|PTE_W)) < 0) panic("sys_page_map failed: %e/n", r); if ((r = sys_page_unmap(0, (void *)PFTEMP)) < 0) panic("sys_page_unmap failed: %e/n", r); //Set child's page fault handler if ((err = sys_env_set_pgfault_upcall(envid, _pgfault_upcall) < 0)) panic("Error in sys_env_set_pgfault_upcall: %e",err); //Set the child ready to run if ((err = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) panic("sys_env_set_status: %e", err); return envid; panic("fork not implemented");}
开发者ID:sumanthkanuparthi,项目名称:Hypervisor,代码行数:76,
示例10: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use vpd, vpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. //panic("fork not implemented"); extern void _pgfault_upcall(void); set_pgfault_handler(pgfault); envid_t id = sys_exofork(); int r; if (id < 0) panic("exofork: child"); if (id == 0) { thisenv = envs + ENVX(sys_getenvid()); return 0; }// cprintf("fork id: %x",id); if ((r=sys_page_alloc(id, (void*)(UXSTACKTOP-PGSIZE), PTE_U | PTE_W | PTE_P))<0) return r; int i; for (i=0;i<UTOP-PGSIZE;i+=PGSIZE) if ((vpd[PDX(i)] & PTE_P) && (vpt[PGNUM(i)] & PTE_P)) {// cprintf("i:%x ",i); if ((r=duppage(id,PGNUM(i)))<0) return r; } if ((r=sys_env_set_pgfault_upcall(id,(void*)_pgfault_upcall))<0) return r; if ((r=sys_env_set_status(id, ENV_RUNNABLE))<0) return r; return id;}
开发者ID:binghe2001021,项目名称:joslabs,代码行数:49,
示例11: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. curenv->env_syscalls++; switch(syscallno){ case SYS_cputs: sys_cputs((char *)a1, (size_t)a2);break; case SYS_cgetc: sys_cgetc();break; case SYS_getenvid: return sys_getenvid(); case SYS_env_destroy: return sys_env_destroy((envid_t)a1); case SYS_dump_env: sys_dump_env();break; case SYS_page_alloc: return sys_page_alloc((envid_t)a1, (void *)a2, (int)a3); case SYS_page_map: { return sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, (int)a5); } case SYS_page_unmap: return sys_page_unmap((envid_t)a1, (void *)a2); case SYS_exofork: return sys_exofork(); case SYS_env_set_status: return sys_env_set_status((envid_t)a1,(int)a2); case SYS_env_set_trapframe: return sys_env_set_trapframe((envid_t)a1, (struct Trapframe *)a2); case SYS_env_set_pgfault_upcall: return sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2); case SYS_yield: sys_yield();break;//new add syscall for lab4; case SYS_ipc_try_send: return sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void *)a3, (unsigned)a4); case SYS_ipc_recv: return sys_ipc_recv((void *)a1); case SYS_ide_read: sys_ide_read((uint32_t)a1, (void *)a2, (size_t)a3); break; case SYS_ide_write: sys_ide_write((uint32_t)a1, (void *)a2, (size_t)a3); break; case SYS_time_msec: return sys_time_msec(); case NSYSCALLS: break; default: return -E_INVAL; } return 0; //panic("syscall not implemented");}
开发者ID:ichaos,项目名称:jos,代码行数:60,
示例12: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. int32_t ret = -E_INVAL; switch(syscallno) { case SYS_cputs: sys_cputs((char *)a1, a2); break; case SYS_cgetc: ret = sys_cgetc(); break; case SYS_getenvid: ret = sys_getenvid(); break; case SYS_env_destroy: ret = sys_env_destroy(a1); break; case SYS_yield: sys_yield(); ret = 0; break; case SYS_map_kernel_page: ret = sys_map_kernel_page((void *)a1, (void *)a2); break; case SYS_sbrk: ret = sys_sbrk(a1); break; case SYS_exofork: ret = sys_exofork(); break; case SYS_env_set_status: ret = sys_env_set_status(a1,a2); break; case SYS_page_alloc: ret = sys_page_alloc(a1,(void*)a2,a3); break; case SYS_page_map: ret = sys_page_map(a1,(void*)a2,a3,(void*)a4,a5); break; case SYS_page_unmap: ret = sys_page_unmap(a1,(void*)a2); break; case SYS_env_set_pgfault_upcall: ret = sys_env_set_pgfault_upcall(a1,(void*)a2); break; case SYS_ipc_try_send: ret = sys_ipc_try_send(a1,a2,(void*)a3,a4); break; case SYS_ipc_recv: ret = sys_ipc_recv((void*)a1); } return ret;// panic("syscall not implemented");}
开发者ID:binghe2001021,项目名称:joslabs,代码行数:58,
示例13: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. /* lj */ int ret = 0; switch(syscallno) { case SYS_cputs: sys_cputs((const char *)a1, a2); break; case SYS_cgetc: ret = sys_cgetc(); break; case SYS_getenvid: ret = sys_getenvid(); break; case SYS_env_destroy: ret = sys_env_destroy(a1); break; case SYS_yield: sys_yield(); break; case SYS_exofork: ret = sys_exofork(); break; case SYS_env_set_status: ret = sys_env_set_status((envid_t)a1, a2); break; case SYS_page_alloc: ret = sys_page_alloc((envid_t)a1, (void *)a2, a3); break; case SYS_page_map: ret = sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, a5); break; case SYS_page_unmap: ret = sys_page_unmap((envid_t)a1, (void *)a2); break; case SYS_env_set_pgfault_upcall: ret = sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2); break; case SYS_ipc_try_send: ret = sys_ipc_try_send((envid_t)a1, a2, (void *)a3, a4); break; case SYS_ipc_recv: ret = sys_ipc_recv((void *)a1); break; default: ret = -E_INVAL; break; } //panic("syscall not implemented"); //cprintf("%d return to user %d/n", syscallno, ret); return ret;}
开发者ID:dannoy,项目名称:JOS,代码行数:58,
示例14: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. //panic("fork not implemented"); envid_t envid=-1; pte_t ptentry=0, ptable=0, page_num=0; pde_t pdentry=0; uintptr_t addr=0; int pdindex = 0, pte_perm=0, pte_loop=0; int r=-1; //cprintf("/nin fork envid:%x/n", thisenv->env_id); set_pgfault_handler(pgfault); if((envid=sys_exofork())<0) panic("/nCannot create a child process:%e/n",envid); //cprintf("/nenvid of newly created child:%x/n",envid); if (envid == 0) { // We're the child. // The copied value of the global variable 'thisenv' // is no longer valid (it refers to the parent!). // Fix it and return 0. thisenv = &envs[ENVX(sys_getenvid())]; //set_pgfault_handler(pgfault); return 0; } //Incrementing by PGSIZE in loop because 1 page of pgsize corresponds to 1 page taable entry //Incrementing the address by 4MB because uvpd has no entry means 1 uvpd->4 MB region so need to skip it. while(addr<(UXSTACKTOP-PGSIZE)) { //cprintf("parent address:%x",addr); if(uvpd[PDX(addr)] & PTE_P) { if(uvpt[PGNUM(addr)] & PTE_P) { //cprintf("/ncalling duppgae for address %x/n",addr); duppage(envid, PGNUM(addr)); } addr += PGSIZE; } else { addr = addr + PTSIZE; } } if ((r = sys_page_alloc(envid,(void *)UXSTACKTOP-PGSIZE, PTE_P|PTE_U|PTE_W)) < 0) panic("sys_page_alloc: %e", r); if ((r = sys_env_set_pgfault_upcall(envid, _pgfault_upcall)) < 0) panic("pagefault upcall setup error: %e", r); sys_env_set_status(envid, ENV_RUNNABLE); //cprintf("/n fork exiting - envid:%x/n",thisenv->env_id); return envid;}
开发者ID:saurabhgadia4,项目名称:jos-kernel,代码行数:71,
示例15: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use vpd, vpt, and duppage.// Remember to fix "env" and the user exception stack in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. // Assembly language pgfault entrypoint defined in lib/pgfaultentry.S. extern void _pgfault_upcall(void); envid_t chenvid; void *addr; void *addr2; unsigned pn; pte_t pte, pde; int count, r, entries; set_pgfault_handler(pgfault); if ( (chenvid = sys_exofork()) < 0) panic("fork() - no free env!"); else if (chenvid == 0){ //we are in child - ren env = &envs[ENVX(sys_getenvid())]; return 0; } //we are in parent - ren //copy mappings - ren entries = NPDENTRIES; for(addr = 0; entries--; addr+=NPTENTRIES*PGSIZE){ //walk through page directory - ren pde = vpd[PDX(addr)]; if (pde & PTE_P) { //walk through page table - ren for(addr2 = addr, count = NPTENTRIES; ((uintptr_t)addr2 < (uintptr_t)UTOP - PGSIZE) && (count); addr2+=PGSIZE, count--){ pte = vpt[VPN(addr2)]; if (pte & PTE_P){ duppage(chenvid, (uintptr_t)addr2/PGSIZE); } } if (count) break; //reached exception stack - ren } } if( (r = sys_page_alloc(chenvid, (void *) UXSTACKTOP-PGSIZE, PTE_U | PTE_P | PTE_W)) < 0) panic("fork() - could not allocate exception stack for the child!"); if( (r = sys_env_set_pgfault_upcall(chenvid, (void *) _pgfault_upcall)) < 0) panic("fork() - could not set page fault entrypoint for the child!"); if( (r = sys_env_set_status(chenvid, ENV_RUNNABLE)) < 0) panic("fork() - could not set child ENV_RUNNABLE!"); return chenvid;}
开发者ID:ren85,项目名称:jos2006,代码行数:71,
示例16: forkenvid_tfork(void){ // LAB 4: Your code here. // seanyliu int r; int pdidx = 0; int peidx = 0; envid_t childid; set_pgfault_handler(pgfault); // create child environment childid = sys_exofork(); if (childid < 0) { panic("fork: failed to create child %d", childid); } if (childid == 0) { env = &envs[ENVX(sys_getenvid())]; return 0; } // loop through pg dir, avoid user exception stack (which is immediately below UTOP for (pdidx = 0; pdidx < PDX(UTOP); pdidx++) { // check if the pg is present if (!(vpd[pdidx] & PTE_P)) continue; // loop through pg table entries for (peidx = 0; (peidx < NPTENTRIES) && (pdidx*NPDENTRIES+peidx < (UXSTACKTOP - PGSIZE)/PGSIZE); peidx++) { if (vpt[pdidx * NPTENTRIES + peidx] & PTE_P) { if ((r = duppage(childid, pdidx * NPTENTRIES + peidx)) < 0) { panic("fork: duppage failed: %d", r); } } } } // allocate fresh page in the child for exception stack. if ((r = sys_page_alloc(childid, (void *)(UXSTACKTOP - PGSIZE), PTE_U | PTE_P | PTE_W)) < 0) { panic("fork: %d", r); } // parent sets the user page fault entrypoint for the child to look like its own. if ((r = sys_env_set_pgfault_upcall(childid, env->env_pgfault_upcall)) < 0) { panic("fork: %d", r); } // parent marks child runnable if ((r = sys_env_set_status(childid, ENV_RUNNABLE)) < 0) { panic("fork: %d", r); } return childid; //panic("fork not implemented");}
开发者ID:HVNT,项目名称:6.828,代码行数:55,
示例17: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. int32_t r =0; switch(syscallno){ case SYS_cputs: sys_cputs((const char*)a1,(size_t)a2); break; case SYS_cgetc: r = sys_cgetc(); break; case SYS_getenvid: r = sys_getenvid(); break; case SYS_env_destroy: r = sys_env_destroy((envid_t)a1); break; case SYS_yield: sys_yield(); r =0; break; case SYS_exofork: r = sys_exofork(); break; case SYS_env_set_status: r = sys_env_set_status((envid_t)a1,(int)a2); break; case SYS_page_alloc: r = sys_page_alloc((envid_t)a1 ,(void *)a2, (int)a3); break; case SYS_page_map: r = sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, (int)a5); break; case SYS_page_unmap: r = sys_page_unmap((envid_t)a1,(void *)a2); break; case SYS_env_set_pgfault_upcall: r = sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2); break; case SYS_ipc_try_send: r = sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void *)a3, (unsigned int)a4); break; case SYS_ipc_recv: r = sys_ipc_recv((void *)a1); break; default: r = -E_INVAL; } return r; panic("syscall not implemented");}
开发者ID:yaobaiwei,项目名称:JOS,代码行数:55,
示例18: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here.// panic("syscall not implemented"); switch (syscallno) { case SYS_cputs: sys_cputs((char *)a1, a2); break; case SYS_cgetc: return sys_cgetc(); case SYS_env_destroy: return sys_env_destroy(a1); case SYS_getenvid: return sys_getenvid(); case SYS_yield: sys_yield(); break; case SYS_page_alloc: return sys_page_alloc(a1, (void *)a2, a3); case SYS_page_map: return sys_page_map(a1, (void *)a2, a3, (void *)a4, a5); case SYS_page_unmap: return sys_page_unmap(a1, (void *)a2); case SYS_env_set_status: return sys_env_set_status(a1, a2); case SYS_exofork: return sys_exofork(); case SYS_env_set_pgfault_upcall: return sys_env_set_pgfault_upcall(a1, (void *)a2); case SYS_ipc_try_send: return sys_ipc_try_send(a1, a2, (void*)a3, a4); case SYS_ipc_recv: return sys_ipc_recv((void*)a1); case SYS_env_set_trapframe: return sys_env_set_trapframe(a1, (struct Trapframe *)a2); case SYS_time_msec: return sys_time_msec(); case SYS_trans_pkt: return sys_trans_pkt((void*)a1, a2); case SYS_recv_pkt: return sys_recv_pkt((void *)a1, (size_t *)a2); default: return -E_INVAL; } return 0;}
开发者ID:Cai41,项目名称:mit-6.828,代码行数:53,
示例19: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. switch (syscallno){ case SYS_getenvid: return sys_getenvid(); case SYS_cputs: sys_cputs((const char*)a1, a2); return 0; case SYS_cgetc: return sys_cgetc(); case SYS_env_destroy: return sys_env_destroy(a1); case SYS_map_kernel_page: return sys_map_kernel_page((void*)a1, (void*)a2); case SYS_sbrk: return sys_sbrk(a1); case SYS_yield: sys_yield(); return 0; case SYS_exofork: return sys_exofork(); case SYS_env_set_status: return sys_env_set_status((envid_t)a1, (int)a2); case SYS_page_alloc: return sys_page_alloc((envid_t)a1, (void *)a2, (int)a3); case SYS_page_map: return sys_page_map((envid_t)*((uint32_t*)a1), (void*)*((uint32_t*)a1+1), (envid_t)*((uint32_t*)a1+2), (void*)*((uint32_t*)a1+3), (int)*((uint32_t*)a1+4)); case SYS_page_unmap: return sys_page_unmap((envid_t)a1, (void*)a2); case SYS_env_set_priority: return sys_env_set_priority((envid_t)a1, (int) a2); case SYS_env_set_pgfault_upcall: return sys_env_set_pgfault_upcall((envid_t)a1, (void*)a2); case SYS_ipc_recv: return sys_ipc_recv((void*)a1); case SYS_ipc_try_send: return sys_ipc_try_send((envid_t)a1, a2, (void*)a3, (int)a4); default: return -E_INVAL; }}
开发者ID:yuki252111,项目名称:os,代码行数:53,
示例20: syscall// Dispatches to the correct kernel function, passing the arguments. int64_tsyscall(uint64_t syscallno, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. uint64_t retval = 0; switch (syscallno) { case SYS_cputs: sys_cputs((char *) a1, (size_t) a2); return retval; case SYS_cgetc: return (int64_t) sys_cgetc(); case SYS_getenvid: return (int64_t) sys_getenvid(); case SYS_env_destroy: return (int64_t) sys_env_destroy((envid_t) a1); case SYS_yield: sys_yield(); return retval; case SYS_exofork: return (int64_t)sys_exofork(); case SYS_page_alloc: return (int64_t)sys_page_alloc((envid_t)a1, (void *)a2, (int)a3); case SYS_page_map: return (int64_t)sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, (int)a5); case SYS_page_unmap: return (int64_t)sys_page_unmap((envid_t)a1, (void *)a2); case SYS_env_set_status: return (int64_t)sys_env_set_status((envid_t)a1, (int)a2); case SYS_env_set_pgfault_upcall: return (int64_t)sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2); case SYS_ipc_try_send: return (int64_t) sys_ipc_try_send((envid_t) a1, (uint32_t) a2, (void *) a3, (unsigned) a4); case SYS_ipc_recv: return (int64_t)sys_ipc_recv((void*)a1); case SYS_env_set_trapframe: return sys_env_set_trapframe((envid_t)a1, (struct Trapframe*)a2); case SYS_time_msec: return sys_time_msec(); case SYS_net_try_send: return sys_net_try_send((char *) a1, (int) a2); case SYS_net_try_receive: return sys_net_try_receive((char *) a1, (int *) a2); default: return -E_INVAL; } panic("syscall not implemented");}
开发者ID:ajsbu,项目名称:cse506,代码行数:52,
示例21: sfork// Challenge!intsfork(void){ int r; pde_t *pde; pte_t *pte; unsigned i; uint32_t addr; envid_t envid; envid = sys_exofork();//创建子环境 if(envid < 0) panic("sys_exofork: %e", envid); if(envid==0)//子环境中 { env = &envs[ENVX(sys_getenvid())]; return 0; } else{//父环境中,注意:这里需要设置父环境的缺页异常栈,还需要设置子环境的缺页异常栈, //父子环境的页异常栈不共享?具体原因还得思考 env = &envs[ENVX(sys_getenvid())]; set_pgfault_handler(pgfault);//设置缺页异常处理函数,这里设置了父环境的缺页异常栈 for(i=0;i<(unsigned)VPN(UTOP);i++)//重映射writable or copy-to-write的页面 { addr=i*PGSIZE; pde =(pde_t*) &vpd[VPD(addr)]; if(*pde&PTE_P)//这里只处理有物理页面映射的页表项 { pte=(pte_t*)&vpt[VPN(addr)]; } else continue; if((i==(unsigned)VPN(USTACKTOP-PGSIZE))||(i==(unsigned)VPN(PFTEMP))) //特殊处理,用户层普通栈 { if((r=duppage(envid,i))<0) return r; continue; } if((r=sduppage(envid,i))<0) return r; } if((r=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_W|PTE_U|PTE_P))<0) return r;//设置子环境的缺页异常栈 if((r=sys_env_set_pgfault_upcall(envid,(void*)_pgfault_upcall))<0) return r;//设置子环境的缺页异常处理入口点 if((r=sys_env_set_status(envid,ENV_RUNNABLE))<0) return r;//设置子环境的状态为可运行 return envid; } //panic("sfork not implemented"); //return -E_INVAL;}
开发者ID:wuxy,项目名称:mitjos,代码行数:52,
示例22: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. set_pgfault_handler(pgfault); envid_t childid = sys_exofork(); if(childid < 0) panic("Fork Failed/n"); if(childid == 0) { thisenv = &envs[ENVX(sys_getenvid())]; return 0; } int i, j; for(i = 0; i < PDX(UTOP); i++) { if (!(uvpd[i] & PTE_P)) continue; for(j = 0; (j < 1024) && (i*NPDENTRIES + j < PGNUM(UXSTACKTOP - PGSIZE)); j++ ) { if(!uvpt[i*NPDENTRIES + j] & PTE_P) continue; if(duppage(childid, i*NPDENTRIES + j) < 0) panic("dup page failed"); } } if ((sys_page_alloc(childid, (void *)(UXSTACKTOP - PGSIZE), PTE_U | PTE_P | PTE_W)) < 0) { panic("Allocation of page for Exception stack cups!/n"); } if ((sys_env_set_pgfault_upcall(childid, thisenv->env_pgfault_upcall)) < 0) { panic("Unable to set child process' upcall"); } // Copy own uxstack to temp page memmove((void *)(UXSTACKTOP - PGSIZE), PFTEMP, PGSIZE); int r; // Unmap temp page if (sys_page_unmap(sys_getenvid(), PFTEMP) < 0) { return -1; } if ((r = sys_env_set_pgfault_upcall(childid, thisenv->env_pgfault_upcall)) < 0) panic("sys_env_set_pgfault_upcall: error %e/n", r); if ((r = sys_env_set_status(childid, ENV_RUNNABLE)) < 0) { cprintf("sys_env_set_status: error %e/n", r); return -1; } return childid; panic("fork not implemented");}
开发者ID:abhinav2710,项目名称:JOS-MIT6.828,代码行数:66,
示例23: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use uvpd, uvpt, and duppage.// Remember to fix "thisenv" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. int r; envid_t child_envid; set_pgfault_handler(pgfault); child_envid = sys_exofork(); if (child_envid < 0) panic("sys_exofork: %e/n", child_envid); if (child_envid == 0) { // child // Fix thisenv like dumbfork does and return 0 thisenv = &envs[ENVX(sys_getenvid())]; return 0; } // We're in the parent // Iterate over all pages until UTOP. Map all pages that are present // and let duppage worry about the permissions. // Note that we don't remap anything above UTOP because the kernel took // care of that for us in env_setup_vm(). uint32_t page_num; pte_t *pte; for (page_num = 0; page_num < PGNUM(UTOP - PGSIZE); page_num++) { uint32_t pdx = ROUNDDOWN(page_num, NPDENTRIES) / NPDENTRIES; if ((uvpd[pdx] & PTE_P) == PTE_P && ((uvpt[page_num] & PTE_P) == PTE_P)) { duppage(child_envid, page_num); } } // Allocate exception stack space for child. The child can't do this themselves // because the mechanism by which it would is to run the pgfault handler, which // needs to run on the exception stack (catch 22). if ((r = sys_page_alloc(child_envid, (void *) (UXSTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0) panic("sys_page_alloc: %e/n", r); // Set page fault handler for the child if ((r = sys_env_set_pgfault_upcall(child_envid, _pgfault_upcall)) < 0) panic("sys_env_set_pgfault_upcall: %e/n", r); // Mark child environment as runnable if ((r = sys_env_set_status(child_envid, ENV_RUNNABLE)) < 0) panic("sys_env_set_status: %e/n", r); return child_envid;}
开发者ID:1060351485,项目名称:6.828-JOS,代码行数:66,
示例24: dumbforkenvid_tdumbfork(void){ envid_t envid; uint8_t *addr; int r; extern unsigned char end[]; // Allocate a new child environment. // The kernel will initialize it with a copy of our register state, // so that the child will appear to have called sys_exofork() too - // except that in the child, this "fake" call to sys_exofork() // will return 0 instead of the envid of the child. envid = sys_exofork(); if (envid < 0) panic("sys_exofork: %e", envid); if (envid == 0) { // We're the child. // The copied value of the global variable 'thisenv' // is no longer valid (it refers to the parent!). // Fix it and return 0. cprintf("I am the child /n"); thisenv = &envs[ENVX(sys_getenvid())]; return 0; } // We're the parent. // Eagerly copy our entire address space into the child. // This is NOT what you should do in your fork implementation. /* balvisio: * 'end' is a magic symbol automatically generated by the linker, * which points to the end of the dumbfork bss segment. * the first virtual address that the linker did *not* assign * to any code or global variables. (balvisio: Not sure though * need to confirm. In dumbfork it is 0x802008) */ for (addr = (uint8_t*) UTEXT; addr < end; addr += PGSIZE) duppage(envid, addr); // Also copy the stack we are currently running on. duppage(envid, ROUNDDOWN(&addr, PGSIZE)); // Start the child environment running if ((r = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) panic("sys_env_set_status: %e", r); return envid;}
开发者ID:balvisio,项目名称:JOS,代码行数:50,
示例25: fork//// User-level fork with copy-on-write.// Set up our page fault handler appropriately.// Create a child.// Copy our address space and page fault handler setup to the child.// Then mark the child as runnable and return.//// Returns: child's envid to the parent, 0 to the child, < 0 on error.// It is also OK to panic on error.//// Hint:// Use vpd, vpt, and duppage.// Remember to fix "env" in the child process.// Neither user exception stack should ever be marked copy-on-write,// so you must allocate a new page for the child's user exception stack.//envid_tfork(void){ // LAB 4: Your code here. int r; pde_t *pde; pte_t *pte; unsigned i; uint32_t addr; envid_t envid; envid = sys_exofork();//创建子环境 if(envid < 0) panic("sys_exofork: %e", envid); if(envid==0)//子环境中 { env = &envs[ENVX(sys_getenvid())]; return 0; } else{//父环境中 set_pgfault_handler(pgfault);//设置缺页异常处理函数,这里设置了父环境的缺页异常栈 for(i=0;i<(unsigned)VPN(UTOP);i++)//重映射writable or copy-to-write的页面 { if(i==(unsigned)VPN(UXSTACKTOP-PGSIZE))//特殊处理,用户层缺页异常栈 continue; addr=i*PGSIZE; pde =(pde_t*) &vpd[VPD(addr)]; if(*pde&PTE_P)//这里只处理有物理页面映射的页表项 { pte=(pte_t*)&vpt[VPN(addr)]; } else continue; if((*pte&PTE_W)||(*pte&PTE_COW)) { if((r=duppage(envid,i))<0) return r; } } if((r=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_W|PTE_U|PTE_P))<0) return r;//设置子环境的缺页异常栈 if((r=sys_env_set_pgfault_upcall(envid,(void*)_pgfault_upcall))<0) return r;//设置子环境的缺页异常处理入口点 if((r=sys_env_set_status(envid,ENV_RUNNABLE))<0) return r;//设置子环境的状态为可运行 return envid; } //panic("fork not implemented");}
开发者ID:wuxy,项目名称:mitjos,代码行数:63,
示例26: syscall// Dispatches to the correct kernel function, passing the arguments.int32_tsyscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){ // Call the function corresponding to the 'syscallno' parameter. // Return any appropriate return value. // LAB 3: Your code here. switch (syscallno) { case (SYS_cputs): sys_cputs((const char *) a1, a2); return 0; case (SYS_cgetc): return sys_cgetc(); case (SYS_getenvid): return sys_getenvid(); case (SYS_env_destroy): return sys_env_destroy(a1, a2); case (SYS_yield): sys_yield(); return 0; case (SYS_exofork): return sys_exofork(); case (SYS_env_set_status): return sys_env_set_status(a1, a2); case (SYS_page_alloc): return sys_page_alloc(a1, (void *) a2, a3); case (SYS_page_map): return sys_page_map(a1, (void *) a2, a3, (void *) a4, a5); case (SYS_page_unmap): return sys_page_unmap(a1, (void *) a2); case (SYS_env_set_pgfault_upcall): return sys_env_set_pgfault_upcall(a1, (void *) a2); case (SYS_ipc_try_send): return sys_ipc_try_send(a1, a2, (void *) a3, a4); case (SYS_ipc_recv): return sys_ipc_recv((void *) a1); case (SYS_env_set_trapframe): return sys_env_set_trapframe(a1, (struct Trapframe *) a2); case (SYS_time_msec): return sys_time_msec(); case (SYS_e1000_transmit): return sys_e1000_transmit(a1, (char *) a2, a3); default: return -E_INVAL; }}
开发者ID:bdmalab,项目名称:6.828,代码行数:47,
示例27: sfork// Challenge!intsfork(void){/* panic("sfork not implemented"); return -E_INVAL;*/ extern void _pgfault_upcall(void); set_pgfault_handler(pgfault); envid_t id = sys_exofork(); int r; if (id < 0) panic("exofork: child"); if (id == 0) { thisenv = envs + ENVX(sys_getenvid()); return 0; } uint32_t i;/* for (i=0;i<UTOP-PGSIZE;i+=PGSIZE) if ((vpd[PDX(i)] & PTE_P) && (vpt[PGNUM(i)] & PTE_P)) if ((r=duppage(id,PGNUM(i)))<0) return r;*/ if ((r=sys_page_alloc(id, (void*)(UXSTACKTOP-PGSIZE), PTE_U | PTE_W | PTE_P))<0) return r;// cprintf("begin to map!/nUSTACKTOP-PGSIZE: %x/nUTEXT: %x/n",USTACKTOP-PGSIZE,UTEXT); for (i=USTACKTOP-PGSIZE;i>=UTEXT;i-=PGSIZE) { if ((vpd[PDX(i)] & PTE_P) && (vpt[PGNUM(i)] & PTE_P)) { if ((r=sduppage(id,PGNUM(i),1))<0) return r; }else break; } for (;i>=UTEXT;i-=PGSIZE) if ((vpd[PDX(i)] & PTE_P) && (vpt[PGNUM(i)] & PTE_P)) if ((r=sduppage(id,PGNUM(i),0))<0) return r; if ((r=sys_env_set_pgfault_upcall(id,(void*)_pgfault_upcall))<0) return r; if ((r=sys_env_set_status(id, ENV_RUNNABLE))<0) return r;// cprintf("sfork succeed!/n"); return id;}
开发者ID:binghe2001021,项目名称:joslabs,代码行数:46,
示例28: dumbforkenvid_tdumbfork(void){ envid_t envid; uint8_t *addr; int r; extern unsigned char end[]; // Allocate a new child environment. // The kernel will initialize it with a copy of our register state, // so that the child will appear to have called sys_exofork() too - // except that in the child, this "fake" call to sys_exofork() // will return 0 instead of the envid of the child. envid = sys_exofork(); if (envid < 0) { panic("sys_exofork: %e", envid); } if (envid == 0) { // We're the child. // The copied value of the global variable 'env' // is no longer valid (it refers to the parent!). // Fix it and return 0. env = &envs[ENVX(sys_getenvid())]; return 0; } // We're the parent. // Eagerly copy our entire address space into the child. // This is NOT what you should do in your fork implementationp. for (addr = (uint8_t*) UTEXT; addr < end; addr += PGSIZE) duppage(envid, addr); // Also copy the stack we are currently running on. duppage(envid, ROUNDDOWN(&addr, PGSIZE)); // Start the child environment running if ((r = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) { panic("sys_env_set_status: %e", r); } return envid;}
开发者ID:sunuslee,项目名称:sunus_jos,代码行数:44,
注:本文中的sys_env_set_status函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ sys_err函数代码示例 C++ sys_env_set_pgfault_upcall函数代码示例 |