What is the procedure of a function call?

Source: Internet
Author: User

What is the procedure of the function call, what is the stack out of the stack,

When another function is called during the run of a function, the system needs to complete three things before running the called function.

  1. All the actual parameters, the return address and other information are passed to the tuned function to save,
  2. Allocating storage space for local variables (also including formal parameters) of the modulated function
  3. Transfer control to the entry of the transferred function,

There are three things that the system has to do before returning from the tuned function to the keynote function.

  1. Save the returned result of the tuned function,
  2. Releases the storage space occupied by the tuned function,
  3. Transfers control to the calling function according to the return address saved by the tuned function.

When more than one function calls each other, according to the principle of returning first, the information transfer and control transfer between the above functions must be implemented by the stack, that is, the system arranges the data space required by the whole program to run in a stack, whenever a function is called, a storage area is allocated at the top of the stack, and a stack operation is performed. Whenever a function exits, the store is freed, and a stack operation is performed, and the currently running function is always at the top of the stack.

What is the procedure of a function call?

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.