Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Run-Time Storage Management - Code Generation, Computer Science and IT Engineering

Run-Time Storage Management - Code Generation, Computer Science and IT Engineering - Computer Science Engineering (CSE) PDF Download

RUN-TIME STORAGE MANAGEMENT

  • Information needed during an execution of a procedure is kept in a block of storage called an activation record, which includes storage for names local to the procedure. The two standard storage allocation strategies are:

1. Static allocation 2. Stack allocation

  • In static allocation, the position of an activation record in memory is fixed at compile time.
  • In stack allocation, a new activation record is pushed onto the stack for each execution of a procedure. The record is popped when the activation ends.
  • The following three-address statements are associated with the run-time allocation and deallocation of activation records:

1.  Call,

2.  Return,

3.   Halt, and

4.   Action, a placeholder for other statements.

  • We assume that the run-time memory is divided into areas for:

1.  Code

2.  Static data

3.  Stack

 

Static allocation

Implementation of call statement:

The codes needed to implement static allocation are as follows:

MOV #here + 20, callee.static_area /*It saves return address*/

GOTO callee.code_area /*It transfers control to the target code for the called

procedure */

where,

callee.static_area - Address of the activation record

callee.code_area - Address of the first instruction for called procedure

#here + 20 - Literal return address which is the address of the instruction following GOTO.

 

Implementation of return statement:

A return from procedure callee is implemented by : GOTO *callee.static_area

This transfers control to the address saved at the beginning of the activation record.

 

Implementation of action statement:

The instruction ACTION is used to implement action statement.

 

Implementation of halt statement:

The statement HALT is the final instruction that returns control to the operating system.

 

Stack allocation

Static allocation can become stack allocation by using relative addresses for storage in activation records. In stack allocation, the position of activation record is stored in register so words in activation records can be accessed as offsets from the value in this register.

The codes needed to implement stack allocation are as follows:

 

Initialization of stack:

MOV #stackstart , SP /* initializes stack */

Code for the first procedure

HALT /* terminate execution */

Run-Time Storage Management - Code Generation, Computer Science and IT Engineering - Computer Science Engineering (CSE)

The document Run-Time Storage Management - Code Generation, Computer Science and IT Engineering - Computer Science Engineering (CSE) is a part of Computer Science Engineering (CSE) category.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

FAQs on Run-Time Storage Management - Code Generation, Computer Science and IT Engineering - Computer Science Engineering (CSE)

1. What is run-time storage management?
Ans. Run-time storage management refers to the process of allocating and managing memory during the execution of a computer program. It involves dynamically allocating memory for variables, data structures, and objects, as well as releasing memory when it is no longer needed.
2. What is code generation in the context of run-time storage management?
Ans. Code generation is the process of translating high-level programming language code into machine code or assembly language code that can be executed by a computer. In the context of run-time storage management, code generation includes the instructions and operations necessary to allocate and deallocate memory dynamically during program execution.
3. What are the main techniques used for run-time storage management?
Ans. The main techniques used for run-time storage management are: - Stack-based allocation: This technique involves using a stack data structure to allocate and deallocate memory. It is efficient and supports automatic memory management, but has limited flexibility. - Heap-based allocation: This technique involves using a heap data structure to allocate and deallocate memory. It provides more flexibility but requires manual memory management and can be prone to memory leaks and fragmentation. - Garbage collection: This technique involves automatically reclaiming memory that is no longer in use by the program. It eliminates the need for manual memory management but can introduce overhead and pause times during garbage collection cycles.
4. What is the role of a memory manager in run-time storage management?
Ans. A memory manager is responsible for allocating and deallocating memory during program execution. It keeps track of available memory blocks, assigns memory to variables and data structures, and releases memory when it is no longer needed. The memory manager also handles memory fragmentation and can optimize memory usage by reusing freed memory blocks.
5. How does run-time storage management impact the performance of a program?
Ans. Run-time storage management can have a significant impact on the performance of a program. Poor memory management can lead to memory leaks, where allocated memory is not properly deallocated, causing the program to consume excessive memory and potentially crash. Inefficient memory allocation and deallocation can also result in memory fragmentation, which slows down memory access and can degrade overall program performance. Proper run-time storage management, on the other hand, ensures efficient memory usage, reduces memory leaks and fragmentation, and improves program performance.
Download as PDF

Top Courses for Computer Science Engineering (CSE)

Related Searches

Extra Questions

,

study material

,

Sample Paper

,

practice quizzes

,

Viva Questions

,

video lectures

,

Run-Time Storage Management - Code Generation

,

Computer Science and IT Engineering - Computer Science Engineering (CSE)

,

mock tests for examination

,

Run-Time Storage Management - Code Generation

,

Free

,

ppt

,

Summary

,

Run-Time Storage Management - Code Generation

,

pdf

,

Previous Year Questions with Solutions

,

past year papers

,

MCQs

,

Exam

,

shortcuts and tricks

,

Important questions

,

Objective type Questions

,

Semester Notes

,

Computer Science and IT Engineering - Computer Science Engineering (CSE)

,

Computer Science and IT Engineering - Computer Science Engineering (CSE)

;