Table of contents (expand)
- Introduction to Computer Science (Informatics. Information. Presentation and processing of information. Number systems. Representation of numbers in a computer. Formalized concept of an algorithm)
- Pascal language (Introduction to Pascal. Standard procedures and functions. Pascal operators)
- Procedures and functions (The concept of an auxiliary algorithm. Procedures in Pascal. Functions in Pascal. Anticipatory descriptions and connection of subroutines. Directive)
- Subroutines (Routine parameters. Subroutine parameter types. String type in Pascal. Procedures and functions for string type variables. Records. Sets)
- Files (Files. File operations. Modules. Types of modules)
- Dynamic memory (Reference data type. Dynamic memory. Dynamic variables. Working with dynamic memory. Untyped pointers)
- Abstract data structures (Abstract data structures. Stacks. Queues)
- Tree Data Structures (Tree data structures. Operations on trees. Examples of implementation of operations)
- Counts (The concept of a graph. Methods of representing a graph. Representation of a graph by a list of incidences. Depth-first traversal algorithm for a graph. Representation of a graph as a list of lists. Breadth-first traversal algorithm for a graph)
- Object data type (Object type in Pascal. The concept of an object, its description and use. Inheritance. Creating instances of objects. Components and scope)
- Methods (Methods. Constructors and destructors. Destructors. Virtual methods. Object data fields and formal method parameters)
- Object Type Compatibility (Encapsulation. Extensible objects. Object type compatibility)
- Assembler (About assembler. Microprocessor software model. User registers. General purpose registers. Segment registers. Status and control registers)
- Registers (Microprocessor system registers. Control registers. System address registers. Debug registers)
- Assembly programs (Assembler program structure. Assembler syntax. Comparison operators. Operators and their precedence. Simplified segment definition directives. Identifiers created by the MODEL directive. Memory models. Memory model modifiers)
- Assembly Instruction Structures (Structure of a machine instruction. Methods for specifying instruction operands. Addressing methods)
- commands (Data transfer commands. Arithmetic commands)
- Control Transfer Commands (Logical commands. Truth table for logical negation. Truth table for logical inclusive OR. Truth table for logical AND. Truth table for logical exclusive OR. Meaning of abbreviations in the jcc command name. List of conditional jump commands for the command. Conditional jump commands and flags)
LECTURE No. 7. Dynamic memory
1. Reference data type. dynamic memory. Dynamic variables
A static variable (statically allocated) is a variable declared explicitly in the program, it is referred to by name. The place in memory for placing static variables is determined when the program is compiled. Unlike such static variables, Pascal programs can create dynamic variables. The main property of dynamic variables is that they are created and memory is allocated for them during program execution.
Dynamic variables are placed in a dynamic memory area (heap-area). A dynamic variable is not specified explicitly in variable declarations and cannot be referred to by name. Such variables are accessed using pointers and references.
A reference type (pointer) defines a set of values that point to dynamic variables of a specific type, called a base type. A reference type variable contains the address of a dynamic variable in memory. If the base type is an undeclared identifier, then it must be declared in the same part of the type declaration as the pointer type.
The reserved word nil denotes a constant with a pointer value that does not point to anything.
Let us give an example of the description of dynamic variables.
var p1, p2 : ^real;
p3, p4 : ^integer;
...
2. Working with dynamic memory. Untyped Pointers
Dynamic Memory Procedures and Functions
1. Procedure New(var p: Pointer).
Allocates space in the dynamic memory area to accommodate the dynamic variable pЛ, and assigns its address to the pointer p.
2. Procedure Dispose(varp: Pointer).
Frees the memory allocated for dynamic variable allocation by the New procedure, and the value of the pointer p becomes undefined.
3. Procedure GetMem(varp: Pointer; size: Word).
Allocates a memory section in the heap-area, assigns the address of its beginning to the p pointer, the size of the section in bytes is specified by the size parameter.
4. Procedure FreeMem(var p: Pointer; size: Word).
Frees the memory area, the beginning address of which is specified by the p pointer, and the size is specified by the size parameter. The value of the pointer p becomes undefined.
5. Procedure Mark(var p: Pointer)
Writes to the pointer p the address of the beginning of a section of free dynamic memory at the time of its call.
6. Procedure Release(var p: Pointer)
Releases a section of dynamic memory, starting from the address written to the pointer p by the Mark procedure, i.e. clears the dynamic memory that was occupied after the call to the Mark procedure.
7. MaxAvaikLongint Function
Returns the length, in bytes, of the longest free heap.
8. MemAvaikLongint Function
Returns the total amount of free dynamic memory in bytes.
9. Helper function SizeOf(X):Word
Returns the amount of bytes occupied by X, where X can be either a variable name of any type or a type name.
The built-in type Pointer denotes an untyped pointer, that is, a pointer that does not point to any particular type. Variables of type Pointer can be dereferenced: specifying the ^ character after such a variable causes an error.
Like the value denoted by nil, Pointer values are compatible with all other pointer types.
Author: Tsvetkova A.V.
<< Back: Dynamic memory (Reference data type. Dynamic memory. Dynamic variables. Working with dynamic memory. Untyped pointers)
>> Forward: Tree Data Structures (Tree data structures. Operations on trees. Examples of implementation of operations)
We recommend interesting articles Section Lecture notes, cheat sheets:
▪ Notaries. Crib
▪ Insurance business. Crib
▪ State and municipal administration. Crib
See other articles Section Lecture notes, cheat sheets.
Read and write useful comments on this article.
<< Back
Latest news of science and technology, new electronics:
The existence of an entropy rule for quantum entanglement has been proven
09.05.2024
Quantum mechanics continues to amaze us with its mysterious phenomena and unexpected discoveries. Recently, Bartosz Regula from the RIKEN Center for Quantum Computing and Ludovico Lamy from the University of Amsterdam presented a new discovery that concerns quantum entanglement and its relation to entropy. Quantum entanglement plays an important role in modern quantum information science and technology. However, the complexity of its structure makes understanding and managing it challenging. Regulus and Lamy's discovery shows that quantum entanglement follows an entropy rule similar to that for classical systems. This discovery opens new perspectives in the field of quantum information science and technology, deepening our understanding of quantum entanglement and its connection to thermodynamics. The results of the study indicate the possibility of reversibility of entanglement transformations, which could greatly simplify their use in various quantum technologies. Opening a new rule ... >>
Mini air conditioner Sony Reon Pocket 5
09.05.2024
Summer is a time for relaxation and travel, but often the heat can turn this time into an unbearable torment. Meet a new product from Sony - the Reon Pocket 5 mini-air conditioner, which promises to make summer more comfortable for its users. Sony has introduced a unique device - the Reon Pocket 5 mini-conditioner, which provides body cooling on hot days. With it, users can enjoy coolness anytime, anywhere by simply wearing it around their neck. This mini air conditioner is equipped with automatic adjustment of operating modes, as well as temperature and humidity sensors. Thanks to innovative technologies, Reon Pocket 5 adjusts its operation depending on the user's activity and environmental conditions. Users can easily adjust the temperature using a dedicated mobile app connected via Bluetooth. Additionally, specially designed T-shirts and shorts are available for convenience, to which a mini air conditioner can be attached. The device can oh ... >>
Energy from space for Starship
08.05.2024
Producing solar energy in space is becoming more feasible with the advent of new technologies and the development of space programs. The head of the startup Virtus Solis shared his vision of using SpaceX's Starship to create orbital power plants capable of powering the Earth. Startup Virtus Solis has unveiled an ambitious project to create orbital power plants using SpaceX's Starship. This idea could significantly change the field of solar energy production, making it more accessible and cheaper. The core of the startup's plan is to reduce the cost of launching satellites into space using Starship. This technological breakthrough is expected to make solar energy production in space more competitive with traditional energy sources. Virtual Solis plans to build large photovoltaic panels in orbit, using Starship to deliver the necessary equipment. However, one of the key challenges ... >>
Random news from the Archive Mission control in a laptop
16.09.2013
On September 14, the Japanese launched a new solid-propellant rocket into space, which was controlled from a simple laptop.
The new Japanese Epsilon solid-propellant rocket was developed by specialists from the JAXA aerospace agency. The Epsilon rocket has 3 stages, is 24 meters high and weighs 91 tons. The small-sized Epsilon launch vehicle successfully launched the SPRINT-A space telescope, designed to observe the planets, into orbit. The telescope was put into orbit at a height of 1000 km and will be used to study the planets of the solar system: Venus, Mars and Jupiter.
One of the main features of this mission is the absence of a familiar element of any space launch: the mission control center (MCC), where about 150 people are usually responsible for various parameters of the rocket and its payload. The Japanese Epsilon rocket with the SPRINT-A satellite cost two laptops, from which all stages of the launch were controlled. The absence of the need to use the MCC reduces the cost of launching cargo into space, which is especially important in the era of commercial space exploration. In this case, the combination of a new control system and a solid rocket launcher made it half the cost ($37 million) to put the space telescope into orbit compared to similar Japanese missions.
Of course, a "portable MCC" is not just laptops with a couple of simple applications. JAXA specialists have created software with artificial intelligence. It is this intelligent software that independently checks numerous systems of the launch vehicle and payload. The software is quite complex, the launch was originally scheduled for August 27, but it was canceled just a few seconds before the launch - the computer issued a warning about the incorrect positioning of the rocket on the site. This case illustrates the capabilities of the new "notebook MCC".
|
Other interesting news:
▪ Jaybird Run Sports Wireless Headphones
▪ Flexible writable memory
▪ Smartphone Oppo A1 Pro
▪ One tenth of new laptops are with touchpads
▪ UV LED L2523UVC
News feed of science and technology, new electronics
Interesting materials of the Free Technical Library:
▪ section of the site Application of microcircuits. Article selection
▪ article Fight windmills. Popular expression
▪ article In which theater were audiences encouraged to sleep? Detailed answer
▪ article Indian gooseberry. Legends, cultivation, methods of application
▪ article All-wave amateur antenna. Encyclopedia of radio electronics and electrical engineering
▪ article Adjustable transformer based on LATR. Encyclopedia of radio electronics and electrical engineering
Leave your comment on this article:
All languages of this page
Home page | Library | Articles | Website map | Site Reviews
www.diagram.com.ua
2000-2024