我正在尝试在 os161 中实现 fork 调用,但运行内核后出现以下错误:
我的 sys_fork 函数的伪流程:
创建新地址空间,陷阱帧
声明新的线程指针——ptrthread——我这里没有分配内存
as_copy(源->目标)
thread fork(name , new trapframe, (unsigned long)ptrthread->vmspace, forkentry 函数, ptrthread)
返回 pid()
伪分叉:
1.new trapframe = forkentry 的陷阱帧 arg
curthread->vmspace = forkentry 的 addrspace arg
激活(curthread->vmspace)
在新的陷阱框中设置一些变量
mips_usermode....
当我运行内核时发生以下错误并且内核停止执行:
sys161: System/161 release 1.14, compiled Aug 24 2011 10:55:58
OS/161 base system version 1.11
Copyright (c) 2000, 2001, 2002, 2003
President and Fellows of Harvard College. All rights rescheduler: Dropping thread <boot/menu>.
panic: Assertion failed: SAME_STACK(curkstack-1, (vaddr_t)tf), at ../../arch/mips/mips/trap.c:220 (mips_trap)
sys161: 930837 cycles (827682k, 0u, 103155i)
sys161: 130 irqs 20 exns 0r/0w disk 0r/279w console 0r/0w/1m emufs 0r/0w net
sys161: Elapsed real time: 0.087962 seconds (10.5823 mhz)
sys161: Elapsed virtual time: 0.037233480 seconds (25 mhz)