lab4从forkrets开始的一些疑问。
匿名2023/07/31 19:51:18提问
    lab4student
329

首先看代码

.globl __trapret
__trapret:
    # restore registers from stack
    popal

    # restore %ds, %es, %fs and %gs
    popl %gs
    popl %fs
    popl %es
    popl %ds

    # get rid of the trap number and error code
    addl $0x8, %esp
    iret

.globl forkrets
forkrets:
    # set stack to this new process's trapframe
    movl 4(%esp), %esp
    jmp 

这里让esp先指到trapframe,然后出栈刷新寄存器,iret后执行预先在中断帧tf->eip保留好的代码。以下是我的疑惑:

Q1:iret这里可以理解是无特权级切换的中断返回,即iret以后esp指向tf->tf_eflags?请问这里的理解正确吗?

Q2:如果我的Q1理解正确,那么接下来就是执行线程的函数,此时的esp指向的tf_eflags,岂不是占用了预先保留的中断帧?万一后续有中断产生是不是会有影响?

PS:不知道为何我在做这个实验的时候无法调试,一旦在cpu_idle设置断点就会报如下的错,make qemu得到的结果正常

回答(1
    推荐问答
      Simple Empty
      暂无数据