Operating system LAB1 (2)

Source: Internet
Author: User

Interrupted for a long time, a look found a little more content.
I'm going to finish.

LAB1 Challenge 1

We need to set up a trap gate for system calls when we set up the interrupt-like scale.
That is
Switching privilege levels with interrupts
to kernel
When calling Tokernel, the kernel stack of the current function is removed from the TSS and the corresponding switch is made because of the privilege and conversion.

Press Stack EFlags CS Eip err trapno ds es SF gs Tregs etc
Push this call stack into the stack

The last execution of push ESP is to put the pointer on the top of the stack at the top of the stack as the tarp parameter TF incoming

Add an additional space in the dispatch to fill in the modified Trapframe

Put a new pointer into the stack

When the POP is returned it will use the new ESP stack as the return
Iret, it's just the right thing to do.
Because the stack when the stack of ESP and SS, but the stack is not required when the ESP and SS so the return of the stack frame is not ESP and SS??

To User
stack frame, but not complete, when stack is pressed
So in another place apply a stack frame full set ESP and SS return

Answer:
As far as hardware is concerned, there are two cases when executing iret, one is the permission level (kernel State or user state) of CS that is saved on the stack, regardless of SS and ESP, and the second is that the permission level saved on the stack is different from the current, and the SS and ESP need to be restored. The task of OS is to use the function of Iret to modify CS without altering the value of other registers.
(So to kernel when Iret will find CS privileges and consistency (has been modified, so there is no ESP and SS))
(to user similarly)

Attached: lab1_prinit_cur_status
Is the privileged bit that outputs the CS segment of the current few registers is also output for checking

Operating system LAB1 (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.