Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

c - OS161:TLB加载失败(OS161 : TLB miss on Load)

I have a TLB miss on load error when I run the fork test , I understand this is due to passing wrong stackptr to mips_usermode , my implementation seems to revolve around few suggestions over here, would be grateful if I get corrected her.

(我在运行fork测试时遇到TLB加载错误,我理解这是由于将错误的stackptr传递给mips_usermode造成的,我的实现似乎围绕着此处的一些建议,如果我纠正了她,将不胜感激。)

My code below is provided as entry point function in thread_fork.

(我的以下代码在thread_fork中作为入口点函数提供。)

Am i missin any thing ?

(我想念什么吗?)

void
enter_forked_process(void *junk,unsigned long num)
{

        kprintf("
 entered enter_fork_process");
        struct trapframe tf = (*((struct trapframe *) junk));


        (void) num;


        kprintf("
 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);
}
  ask by gsb translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to copy parent thread's address space before you call thread_fork , and pass the address space pointer as the second parameter of enter_forked_process .

(在调用thread_fork之前,必须复制父线程的地址空间,并将地址空间指针作为enter_forked_process的第二个参数enter_forked_process 。)

And in enter_forked_process , you have to fill the address space into curthread->t_addrspace .

(在enter_forked_process ,您必须将地址空间填充到curthread->t_addrspace 。)

Otherwise, you'll get the TLB miss on load error, since current thread (the child)'s address space is not initialized.

(否则,由于当前线程(子线程)的地址空间未初始化,因此您将获得TLB miss on load错误。)

For more details about OS161 fork system call, please refer to this blog.

(有关OS161 fork系统调用的更多详细信息,请参阅此博客。)

And child_forkentry there is more or less the same as your enter_forked_process .

(而且child_forkentry与您的enter_forked_process相同。)

http://jhshi.wordpress.com/2012/03/11/os161-fork-system-call/

(http://jhshi.wordpress.com/2012/03/11/os161-fork-system-call/)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...