System stack and user Stack

Source: Internet
Author: User
(1) ESP: Extended Stack pointer with a pointer in its memory, which always points to the top of the stack frame at the top of the system stack.
(2) EBP: extended base pointer, with a pointer in its memory, always pointing to the bottom of a stack frame at the top of the system stack.


System stacks (also called core stacks and kernel stacks) are operating systems in memory.
The main purpose of a space area is:
(1) Save the interrupted scene. For nested interruptions, the field information of the interrupted program is pushed into the system stack in sequence, and the reverse order pops up when the interrupted return result is returned;
(2) Save the parameters, return values, return points, and local variables of the subprograms called by the operating system.
A user stack is an area of a user's process space. It is used to save the local variables of parameters, return values, return points, and subprograms (functions) called by user processes.

So why not use a stack directly? Why waste so much space ?? There are two reasons:


(1) If only the system stack is used. The system stack is generally limited in size. If there are 16 interruptions priorities, the system stack is generally 15 (only 15 low-priority interruptions are saved, and the other high-priority interrupt handling
Program is running), but the user program subroutine call times may be many, that is 15 times after the subroutine call parameters, return values, return points and subroutines (functions) local variables cannot be
The user program cannot run normally ..

(2) If only user stacks are used. We know that the system program needs to run under some protection, while the user stack is in the user space (that is, the CPU is in the user State, and the CPU is protected when it is in the core State ), protection measures (or rather difficult) cannot be provided ).

We know that most of the operating systems are hanging kernel programs (such as interrupt handlers) to running user programs, such:

 

The core program stack is the system stack of the currently running user processes. Each process has its own user stack and system stack. Moreover, the system stack size is determined (depending on the number of Interrupt nesting allowed by the system, that is, the number of Interrupt priorities ).

 

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.