Home Common Problem What is the stack in a computer?

What is the stack in a computer?

Sep 28, 2020 pm 01:10 PM
computer

The stack in the computer is also called a stack. It is a linear list with limited operations. It is a linear list that only performs insertion and deletion operations at the end of the list. This end is called the top of the stack. Relatively speaking, The other end is called the bottom of the stack; inserting a new element into a stack is also called pushing, pushing or pushing. It is to put the new element on top of the top element of the stack, making it the new top element of the stack.

What is the stack in a computer?

Recommended: "Programming Video"

Stack (stack) is also called a stack. A linear table with restricted operations. A linear table that restricts insertion and deletion operations only to the end of the table. This end is called the top of the stack, and the other end is called the bottom. Inserting a new element into a stack is also called pushing, pushing or pushing. It is to put the new element on top of the top element of the stack, making it a new top element; deleting elements from a stack is also called popping or pushing. Pop off the stack, which deletes the top element of the stack and makes its adjacent elements the new top element of the stack.

Basic concepts

To understand this concept, you must first understand the original meaning of "stack", so that you can grasp the essence. "Stack" refers to a place for storing goods or accommodation for passengers, which can be extended to warehouses and transfer stations. Therefore, when introduced into the computer field, it refers to a place where data is temporarily stored, so there are terms of entering and exiting the stack.

First of all, reading and inserting data content in the system or data structure stack (push and pop) are two different things! Pushing is to add data, and popping is to delete data. These operations can only be performed from the top of the stack, that is, the interface interface with the lowest address as a constraint, but reading the data in the stack is casual and there is no interface constraint. Many people misunderstand this concept and are confused about the stack. The system stack also serves as a media area for cross-component interaction in the computer architecture, that is, the communication channel between the CPU and the memory. The CPU only linearly reads execution instructions from the stack entry specified by the system for the application program we write. , using an image word to describe it is pipeline (pipeline, assembly line). For details on the internal interaction of the CPU, see the introduction to the concepts of EU and BIU.

Stack, as a data structure, is a special linear table that can only perform insertion and deletion operations at one end. It stores data according to the principle of first in, last out. The data that enters first is pushed to the bottom of the stack, and the last data is on the top of the stack. When data needs to be read, data is popped from the top of the stack (the last data is read out first). The stack has a memory function. During insertion and deletion operations on the stack, there is no need to change the bottom pointer of the stack.

A stack is a special linear list that allows insertion and deletion operations at the same end. The end that allows insertion and deletion operations is called the top of the stack, and the other end is the bottom. The bottom of the stack is fixed, and the top of the stack floats. When the number of elements in the stack is zero, it is called an empty stack. Insertion is generally called PUSH, and deletion is called popping (POP). Stack is also called first-in-last-out list.

The stack can be used to store breakpoints when a function is called. The stack is used when doing recursion!

The above definition is explained in classical computer science.

In computer systems, the stack is a dynamic memory area with the above attributes. The program can push data onto the stack or pop data off the top of the stack. In i386 machines, the top of the stack is located by a register called esp. The push operation causes the address at the top of the stack to decrease, and the pop operation causes the address at the top of the stack to increase.

The stack plays an important role in the running of the program. The most important thing is that the stack saves the maintenance information required when a function is called, which is often called a stack frame or activity record. Stack frames generally contain the following aspects of information:

1. The return address and parameters of the function

2. Temporary variables: including non-static local variables of functions and other temporary variables automatically generated by the compiler.

What is the stack in a computer?

The above is the detailed content of What is the stack in a computer?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

2024 CSRankings National Computer Science Rankings Released! CMU dominates the list, MIT falls out of the top 5 2024 CSRankings National Computer Science Rankings Released! CMU dominates the list, MIT falls out of the top 5 Mar 25, 2024 pm 06:01 PM

2024 CSRankings National Computer Science Rankings Released! CMU dominates the list, MIT falls out of the top 5

Remote Desktop cannot authenticate the remote computer's identity Remote Desktop cannot authenticate the remote computer's identity Feb 29, 2024 pm 12:30 PM

Remote Desktop cannot authenticate the remote computer's identity

What is e in computer What is e in computer Aug 31, 2023 am 09:36 AM

What is e in computer

Fix: Microsoft Teams error code 80090016 Your computer's Trusted Platform module has failed Fix: Microsoft Teams error code 80090016 Your computer's Trusted Platform module has failed Apr 19, 2023 pm 09:28 PM

Fix: Microsoft Teams error code 80090016 Your computer's Trusted Platform module has failed

What does computer cu mean? What does computer cu mean? Aug 15, 2023 am 09:58 AM

What does computer cu mean?

Unable to open the Group Policy object on this computer Unable to open the Group Policy object on this computer Feb 07, 2024 pm 02:00 PM

Unable to open the Group Policy object on this computer

Unable to copy data from remote desktop to local computer Unable to copy data from remote desktop to local computer Feb 19, 2024 pm 04:12 PM

Unable to copy data from remote desktop to local computer

What should I do if steam cannot connect to the remote computer? What should I do if steam cannot connect to the remote computer? Mar 01, 2023 pm 02:20 PM

What should I do if steam cannot connect to the remote computer?