当我运行fork测试时,我在加载错误时有一个TLB未命中,我知道这是由于将错误的stackptr传递给mips_usermode,我的实现似乎围绕着这里的一些建议,如果我能得到纠正,将不胜感激。下面的代码是作为thread_fork中的入口点函数提供的。我错过了什么吗?
void
enter_forked_process(void *junk,unsigned long num)
{
kprintf("\n entered enter_fork_process");
struct trapframe tf = (*((struct trapframe *) junk));
(void) num;
kprintf("\n copied tf from from parent to child");
tf.tf_v0 = 0;
tf.tf_a3 = 0;
tf.tf_epc += 4;
kprintf("abt to enter mips_ usermode");
mips_usermode(&tf);
}发布于 2012-03-28 15:15:37
在调用thread_fork之前,您必须复制父线程的地址空间,并将地址空间指针作为enter_forked_process的第二个参数传递。在enter_forked_process中,您必须将地址空间填充到curthread->t_addrspace中。否则,您将得到TLB miss on load错误,因为当前线程(子线程)的地址空间尚未初始化。
有关OS161分叉系统调用的更多详细信息,请参阅此博客。和你的enter_forked_process大同小异。http://jhshi.me/2012/03/11/os161-fork-system-call/index.html
https://stackoverflow.com/questions/9881404
复制相似问题