SlideShare a Scribd company logo
RUN TIME ADMINISTRATION
• STORAGE ALLOCATION STRATEGIES.
• A BRIEF COMPARISON BETWEEN
STORAGE ALLOCATION STRATEGIES.
• ACCESS TO NON LOCAL NAMES.
• BLOCK STRUCTURE STORAGE
ALLOCATION.
• ACTIVATION RECORD.
Storage allocation strategies-
Static
Stack
Heap Stack-based Allocation.
Storage is organized as a stack.
Activation records are pushed and
popped.
Ex :- Pascal , C
Heap Allocation
The storage is allocated and deallocated
at runtime from a data area known as
heap
Ex :- Pascal
Static Allocation.
Storage is allocated for all data objects
at compile time
Ex :- Fortran
Static Allocation
In this allocation scheme, the
compilation data is bound to
a fixed location in the
memory and it does not
change when the program
executes.
As the memory requirement
and storage locations are
known in advance,
runtime support package for
memory allocation and de-
allocation is not
required.
Static Allocation
 Statically allocated names are bound to relocatable storage
at compile time.
 Storage bindings of statically allocated names never change.
 The compiler uses the type of a name (retrieved from the
symbol table) to determine storage size required.
 The required number of bytes (possibly aligned) is set aside
for the name.
 The relocatable address of the storage is fixed at compile
time.
Static Allocation
 In a static environment (Fortran 77) there are a number of
restrictions:
 Size of data objects are known at compile time
 No recursive procedures
 No dynamic memory allocation
 Only one copy of each procedure activation record exists at
time t
 We can allocate storage at compile time
• Bindings do not change at runtime
• Every time a procedure is called, the same bindings
occur
Static Allocation
 Limitations:
 The size required must be known at compile time.
 Recursive procedures cannot be implemented statically.
 No data structure can be created dynamically as all data is
static.
Stack Allocation
Procedure calls and their
activations are managed by
means of stack memory
allocation.
It works in last-in-first-out LIFO
method and this allocation
strategy is very useful for
recursive procedure
calls.
Stack Allocation
 In a stack-based allocation, the previous restrictions are lifted
(Pascal, C, etc)
 Procedures are allowed to be called recursively
• Need to hold multiple activation records for the same
procedure
• Created as required and placed on the stack
 Each record will maintain a pointer to the record that
activated it
 On completion, the current record will be deleted
from the stack and control is passed to the calling
record
 Dynamic memory allocation is allowed
 Pointers to data locations are allowed
Stack Allocation
 Storage is organized as a stack.
 Activation records are pushed and popped.
 Locals and parameters are contained in the activation records
for the call.
 This means locals are bound to fresh storage on every call.
 We just need a stack_top pointer.
 To allocate a new activation record, we just increase stack_top.
 To deallocate an existing activation record, we just decrease
stack_top
Stack Allocation
Advantages
 It supports recursion as memory is always allocated on
block entry.
 It allows to create data structures dynamically.
 It allows an array declaration like A(I, J), since actual
allocation is made only at execution time. The dimension
bounds need not be known at compile time.
Disadvantages:
 Memory addressing has to be effected through pointers and
index registers which may be store them, static allocation
especially in case of array reference.
Heap Allocation
Variables local to a procedure
are allocated and de-allocated
only at runtime. Heap allocation
is used to dynamically allocate
memory to the variables and
claim it back when the variables
are no more required.
Except statically allocated
memory area, both stack and
heap memory can grow and
shrink dynamically and
unexpectedly. Therefore, they
cannot be provided with a fixed
amount of
memory in the system.
Heap Allocation
Stack allocation cannot be used if:
 The values of the local variables must be retained when an
activation ends
 A called activation outlives the caller
 In such a case de-allocation of activation record cannot occur
in last-in first-out fashion
 Heap allocation gives out pieces of contiguous storage for
activation record
Heap Allocation
There are two aspects of dynamic allocation :
 Runtime allocation and de-allocation of data structures
 Languages like Algol have dynamic data structures and it
reserves some part of memory for it.
If a procedure wants to put a value that is to be used after its
activation is over then we cannot use stack for that purpose. That
is language like Pascal allows data to be allocated under program
control. Also in certain language a called activation may outlive the
caller procedure. In such a case last-in-first-out queue will not
work and we will require a data structure like heap to store the
activation. The last case is not true for those languages whose
activation trees correctly depict the flow of control between
procedures.
Heap Allocation
 Some languages do not have tree-structured allocations.
 In these cases, activations have to be allocated on the heap.
 This allows strange situations, like called activations that live
longer than their callers’ activations.
 This is not common.
 Pieces may be de-allocated in any order.
 Over time the heap will consist of alternate areas that are
free and in use.
Heap Allocation
 Heap manager is supposed to make use of the free space.
 For efficiency reasons it may be helpful to handle small
activations as a special case.
 For each size of interest keep a linked list of free blocks of
that size.
 Fill a request of size s with block of size s ' where s ' is the
smallest size greater than or equal to s
 For large blocks of storage use heap manager
Heap Allocation
 For large amount of storage computation may take some time
to use up memory so that time taken by the manager may be
negligible compared to the computation time
 For efficiency reasons we can handle small activations and
activations of predictable size as a special case as follows:
1. For each size of interest, keep a linked list if free blocks
of that size
2. If possible, fill a request for size s with a block of size s',
where s' is the smallest size greater than or equal to s.
When the block is eventually de-allocated, it is returned
to the linked list it came from.
Heap Allocation
3. For large blocks of storage use the heap manager.
 Heap manger will dynamically allocate memory. This will
come with a runtime overhead. As heap manager will
have to take care of defragmentation and garbage
collection. But since heap manger saves space otherwise
we will have to fix size of activation at compile time,
runtime overhead is the price worth it
Sr no. Static allocation Stack allocation Heap allocation
1.
Static Allocation is
done for all data
objects at compile
time
In stack allocation,
stack is used to
manage runtime
In heap allocation,
heap is used to
manage dynamic
memory allocation
2.
Data structures can
not be created
dynamically as the
amount of data
storage required by
each data object is
determined by
compiler
Data structures and
data objects can
be created
dynamically
Data structures and
data objects can be
created
dynamically
Sr no. Static allocation Stack allocation Heap allocation
3.
Memory allocation:
The names of data
objects are bound
to storage at
compile time.
Memory allocation:
Using ( LIFO )
activation records
and data objects
are pushed onto
the stack. Memory
addressing can be
done using index
and registers.
Memory allocation:
A contiguous block
of memory from
heap is allocated
for activation
record or data
object . A linked list
is maintained for
free blocks.
Access to non-local
names
Scope rules determine the
treatment of non-local names.
A common rule is lexical scoping
or static scoping (most
languages use lexical scoping).
The scope rules of a language
decide how to reference the
non-local variables.
.
Access to non-local names
 There are two methods that are commonly used :
1. Static or Lexical scoping : It determines the
declaration that applies to a name by examining the
program text alone.
Ex :- Pascal, C and ADA.
2. Dynamic Scoping : It determines the declaration
applicable to a name at run time by considering
the current activations.
Ex :- Lisp
Access to non-local names
Static or Lexical scoping
Access Links
 A direct implementation of lexical scope for nested procedures
is obtained be adding a pointer called an access link to each
activation record.
 If procedure p is nested immediately within q in the source text,
then the access link in an activation record for p points to the
access link in the record for the most recent activation of q.
Access to non-local names
Static or Lexical scoping
Displays
 Faster access to non-locals than with access links can be
obtained using an array d of pointers to activation records,
called a display.
 We maintain the display so that storage for a non-
local a at nesting depth i is in the activation record pointed to
by display element d [i].
Access to non-local names
Dynamic scoping
Deep Access
 Conceptually, dynamic scope results if access links point to the
same activation records that control links do.
 A simple implementation is to dispense with access links and
use the control link to search into the stack, looking for the first
activation record containing storage for the non-local name.
 The term deep access comes from the fact that the search may
go "deep" into the stack.
Access to non-local names
Dynamic scoping
Shallow Access
 Here the idea is to hold the current value of each name in
statically allocated storage.
 When a new activation of a procedure p occurs, a local name
n in p takes over the storage statically allocated for n.
 The previous value of n can be saved in the activation record
for p and must be restored when the activation of p ends.
Block
Blocks can be nested
The property is referred to as
block structured
Blocks are simpler to handle
than procedures
Block
 Blocks can be nested.
 The property is referred to as block structured.
 Blocks are simpler to handle than procedures
 Blocks can be treated as parameter less procedures
 Use stack for memory allocation
 Allocate space for complete procedure body at one time
Block
 Scope of the declaration is given by most closely nested rule
• The scope of a declaration in block B includes B
• If a name X is not declared in B then an occurrence of X is in
the scope of declarator X in B ' such that
o B ' has a declaration of X
o B ' is most closely nested around B
Block
 There are two methods of implementing block structure :
1. Stack Allocation : This is based on the observation that
scope of a declaration does not extend outside the block in
which it appears, the space for declared name can
be allocated when the block is entered and de-allocated
when controls leave the block. The view treat block as a
“parameter less procedure” called only from the point
just before the block and returning only to the point just
before the block.
Block
 There are two methods of implementing block structure :
2. Complete Allocation : Here you allocate the complete
memory at one time. If there are blocks within the
procedure, then allowance is made for the storage needed
for declarations within the books. If two variables are
never alive at the same time and are at same depth they
can be assigned same storage.
Activation
Record
The activation record is a
block of memory used for
managing information
needed by a single execution
of procedure
FORTRAN uses the static data
area to store the activation
record where as in PASCAL
and C the activation record is
situated in stack area
Activation record
 information needed by a single execution
of a procedure is managed using activation
record or frame:
• Not all compilers use all of the fields
• Pascal and C push activation record
on the run time stack when procedure
is called and pop the activation record
off the stack when control returns to
the caller
Activation record
1. Temporary values :-
Arising in the evaluation of expression
2. Local data :-
Data that is local to the execution of the
procedure
3. Saved machine status :-
State of the machine info before
procedure is called. Values of program
counter and machine registers that have to be restored when
control returns from the procedure .
Activation record
4. Access links :-
refers non local data held in other activation
records.
5. Control link :-
points to the activation record of the caller.
6. Actual parameters :-
used by the calling procedure to supply
parameters to the called procedure .
[ in practice these are passed in registers ]
7. Returned values :-
used by the called procedures to return a value to the calling
procedure.
[ in practice it is returned in a register ]
Activation record
The activation call for
factorial(3)
EXAMPLE
Activation record
REFERENCES
 www.slideshare.com
 Aho, Sethi & Ullman, “Compilers: Principles, Techniques and
Tools”, Pearson Education
 V Raghvan, “Principles of Compiler Design”, TMH
BY:
THANK
YOU
VIVEK BHUSHAN TIWARI
NILANSHI NIGAM
ARJUN SRIVASTAVA
ALANKAR MISHRA
RIYA AGARWAL

More Related Content

What's hot

Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
Iffat Anjum
 
Mass Storage Structure
Mass Storage StructureMass Storage Structure
Mass Storage Structure
Vimalanathan D
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
Janki Shah
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
abdosaidgkv
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chips
Anuj Modi
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
Kumar Pritam
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Darshan sai Reddy
 
Memory allocation (4)
Memory allocation (4)Memory allocation (4)
Memory allocation (4)
rockymani
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208
Ameer Mehmood
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
Kamal Acharya
 
Active database
Active databaseActive database
Active database
mridul mishra
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
Piyush Rochwani
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
Memory management
Memory managementMemory management
Memory management
Rajni Sirohi
 
Memory Allocation to a process
Memory Allocation to a processMemory Allocation to a process
Memory Allocation to a process
Meghaj Mallick
 
Interrupts
InterruptsInterrupts
Interrupts
Urwa Shanza
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
Adeel Rasheed
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 

What's hot (20)

Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Mass Storage Structure
Mass Storage StructureMass Storage Structure
Mass Storage Structure
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
 
Memory management
Memory managementMemory management
Memory management
 
Ram and-rom-chips
Ram and-rom-chipsRam and-rom-chips
Ram and-rom-chips
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Memory allocation (4)
Memory allocation (4)Memory allocation (4)
Memory allocation (4)
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
 
Active database
Active databaseActive database
Active database
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Stack organization
Stack organizationStack organization
Stack organization
 
Memory management
Memory managementMemory management
Memory management
 
Memory management
Memory managementMemory management
Memory management
 
Memory Allocation to a process
Memory Allocation to a processMemory Allocation to a process
Memory Allocation to a process
 
Interrupts
InterruptsInterrupts
Interrupts
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 

Viewers also liked

The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
Shabeen Taj
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
Vipul Naik
 
Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
WBUTTUTORIALS
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
Anul Chaudhary
 
Back patching
Back patchingBack patching
Back patching
santhiya thavanthi
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
19magnet
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
Iffat Anjum
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
Jenny Galino
 
Code generation
Code generationCode generation
Code generation
Aparna Nayak
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
bolovv
 
Control Flow Analysis
Control Flow AnalysisControl Flow Analysis
Control Flow Analysis
Edgar Barbosa
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
koolkampus
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
rawan_z
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
Shine Raj
 
Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)
Tech_MX
 
CBSE XII Boolean Algebra
CBSE XII Boolean AlgebraCBSE XII Boolean Algebra
CBSE XII Boolean Algebra
Guru Ji
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
BBDITM LUCKNOW
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
 
Module 11
Module 11Module 11
Module 11
bittudavis
 

Viewers also liked (20)

The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Back patching
Back patchingBack patching
Back patching
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Code generation
Code generationCode generation
Code generation
 
Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
Control Flow Analysis
Control Flow AnalysisControl Flow Analysis
Control Flow Analysis
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)
 
CBSE XII Boolean Algebra
CBSE XII Boolean AlgebraCBSE XII Boolean Algebra
CBSE XII Boolean Algebra
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Module 11
Module 11Module 11
Module 11
 

Similar to Run time administration

Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPTMemory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
AkhilMishra50
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
Rahul Jamwal
 
Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdf
Himanshu883663
 
Unit 5
Unit 5Unit 5
Compiler 2011-8-re1
Compiler 2011-8-re1Compiler 2011-8-re1
Compiler 2011-8-re1
Ganesh Amirineni
 
Compiler 2011-8-re1
Compiler 2011-8-re1Compiler 2011-8-re1
Compiler 2011-8-re1
Ganesh Amirineni
 
SAP HANA Interview questions
SAP HANA Interview questionsSAP HANA Interview questions
SAP HANA Interview questions
IT LearnMore
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache Implementation
Ranjan Kumar
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
C.U
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
Johan Granados Montero
 
Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2
Iffat Anjum
 
Bab 4
Bab 4Bab 4
Bab 4
n k
 
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
DB Tsai
 
Data structure
Data structureData structure
Data structure
krishna partiwala
 
Stacks
StacksStacks
Stacks
Acad
 
CPU Caching Concepts
CPU Caching ConceptsCPU Caching Concepts
CPU Caching Concepts
Abhijit K Rao
 
Megastore by Google
Megastore by GoogleMegastore by Google
Megastore by Google
Ankita Kapratwar
 
Operating system
Operating systemOperating system
Operating system
Hussain Ahmady
 
Policy Driven Dynamic LUN Space Optimization based on the Utilization
Policy Driven Dynamic LUN Space Optimization based on the UtilizationPolicy Driven Dynamic LUN Space Optimization based on the Utilization
Policy Driven Dynamic LUN Space Optimization based on the Utilization
idescitation
 
307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a
vijaysrirams
 

Similar to Run time administration (20)

Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPTMemory Allocation & Direct Memory Allocation in C & C++ Language PPT
Memory Allocation & Direct Memory Allocation in C & C++ Language PPT
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
 
Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdf
 
Unit 5
Unit 5Unit 5
Unit 5
 
Compiler 2011-8-re1
Compiler 2011-8-re1Compiler 2011-8-re1
Compiler 2011-8-re1
 
Compiler 2011-8-re1
Compiler 2011-8-re1Compiler 2011-8-re1
Compiler 2011-8-re1
 
SAP HANA Interview questions
SAP HANA Interview questionsSAP HANA Interview questions
SAP HANA Interview questions
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache Implementation
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2
 
Bab 4
Bab 4Bab 4
Bab 4
 
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
2015 01-17 Lambda Architecture with Apache Spark, NextML Conference
 
Data structure
Data structureData structure
Data structure
 
Stacks
StacksStacks
Stacks
 
CPU Caching Concepts
CPU Caching ConceptsCPU Caching Concepts
CPU Caching Concepts
 
Megastore by Google
Megastore by GoogleMegastore by Google
Megastore by Google
 
Operating system
Operating systemOperating system
Operating system
 
Policy Driven Dynamic LUN Space Optimization based on the Utilization
Policy Driven Dynamic LUN Space Optimization based on the UtilizationPolicy Driven Dynamic LUN Space Optimization based on the Utilization
Policy Driven Dynamic LUN Space Optimization based on the Utilization
 
307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a
 

Recently uploaded

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 

Recently uploaded (20)

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 

Run time administration

  • 1. RUN TIME ADMINISTRATION • STORAGE ALLOCATION STRATEGIES. • A BRIEF COMPARISON BETWEEN STORAGE ALLOCATION STRATEGIES. • ACCESS TO NON LOCAL NAMES. • BLOCK STRUCTURE STORAGE ALLOCATION. • ACTIVATION RECORD.
  • 2. Storage allocation strategies- Static Stack Heap Stack-based Allocation. Storage is organized as a stack. Activation records are pushed and popped. Ex :- Pascal , C Heap Allocation The storage is allocated and deallocated at runtime from a data area known as heap Ex :- Pascal Static Allocation. Storage is allocated for all data objects at compile time Ex :- Fortran
  • 3. Static Allocation In this allocation scheme, the compilation data is bound to a fixed location in the memory and it does not change when the program executes. As the memory requirement and storage locations are known in advance, runtime support package for memory allocation and de- allocation is not required.
  • 4. Static Allocation  Statically allocated names are bound to relocatable storage at compile time.  Storage bindings of statically allocated names never change.  The compiler uses the type of a name (retrieved from the symbol table) to determine storage size required.  The required number of bytes (possibly aligned) is set aside for the name.  The relocatable address of the storage is fixed at compile time.
  • 5. Static Allocation  In a static environment (Fortran 77) there are a number of restrictions:  Size of data objects are known at compile time  No recursive procedures  No dynamic memory allocation  Only one copy of each procedure activation record exists at time t  We can allocate storage at compile time • Bindings do not change at runtime • Every time a procedure is called, the same bindings occur
  • 6. Static Allocation  Limitations:  The size required must be known at compile time.  Recursive procedures cannot be implemented statically.  No data structure can be created dynamically as all data is static.
  • 7. Stack Allocation Procedure calls and their activations are managed by means of stack memory allocation. It works in last-in-first-out LIFO method and this allocation strategy is very useful for recursive procedure calls.
  • 8. Stack Allocation  In a stack-based allocation, the previous restrictions are lifted (Pascal, C, etc)  Procedures are allowed to be called recursively • Need to hold multiple activation records for the same procedure • Created as required and placed on the stack  Each record will maintain a pointer to the record that activated it  On completion, the current record will be deleted from the stack and control is passed to the calling record  Dynamic memory allocation is allowed  Pointers to data locations are allowed
  • 9. Stack Allocation  Storage is organized as a stack.  Activation records are pushed and popped.  Locals and parameters are contained in the activation records for the call.  This means locals are bound to fresh storage on every call.  We just need a stack_top pointer.  To allocate a new activation record, we just increase stack_top.  To deallocate an existing activation record, we just decrease stack_top
  • 10. Stack Allocation Advantages  It supports recursion as memory is always allocated on block entry.  It allows to create data structures dynamically.  It allows an array declaration like A(I, J), since actual allocation is made only at execution time. The dimension bounds need not be known at compile time. Disadvantages:  Memory addressing has to be effected through pointers and index registers which may be store them, static allocation especially in case of array reference.
  • 11. Heap Allocation Variables local to a procedure are allocated and de-allocated only at runtime. Heap allocation is used to dynamically allocate memory to the variables and claim it back when the variables are no more required. Except statically allocated memory area, both stack and heap memory can grow and shrink dynamically and unexpectedly. Therefore, they cannot be provided with a fixed amount of memory in the system.
  • 12. Heap Allocation Stack allocation cannot be used if:  The values of the local variables must be retained when an activation ends  A called activation outlives the caller  In such a case de-allocation of activation record cannot occur in last-in first-out fashion  Heap allocation gives out pieces of contiguous storage for activation record
  • 13. Heap Allocation There are two aspects of dynamic allocation :  Runtime allocation and de-allocation of data structures  Languages like Algol have dynamic data structures and it reserves some part of memory for it. If a procedure wants to put a value that is to be used after its activation is over then we cannot use stack for that purpose. That is language like Pascal allows data to be allocated under program control. Also in certain language a called activation may outlive the caller procedure. In such a case last-in-first-out queue will not work and we will require a data structure like heap to store the activation. The last case is not true for those languages whose activation trees correctly depict the flow of control between procedures.
  • 14. Heap Allocation  Some languages do not have tree-structured allocations.  In these cases, activations have to be allocated on the heap.  This allows strange situations, like called activations that live longer than their callers’ activations.  This is not common.  Pieces may be de-allocated in any order.  Over time the heap will consist of alternate areas that are free and in use.
  • 15. Heap Allocation  Heap manager is supposed to make use of the free space.  For efficiency reasons it may be helpful to handle small activations as a special case.  For each size of interest keep a linked list of free blocks of that size.  Fill a request of size s with block of size s ' where s ' is the smallest size greater than or equal to s  For large blocks of storage use heap manager
  • 16. Heap Allocation  For large amount of storage computation may take some time to use up memory so that time taken by the manager may be negligible compared to the computation time  For efficiency reasons we can handle small activations and activations of predictable size as a special case as follows: 1. For each size of interest, keep a linked list if free blocks of that size 2. If possible, fill a request for size s with a block of size s', where s' is the smallest size greater than or equal to s. When the block is eventually de-allocated, it is returned to the linked list it came from.
  • 17. Heap Allocation 3. For large blocks of storage use the heap manager.  Heap manger will dynamically allocate memory. This will come with a runtime overhead. As heap manager will have to take care of defragmentation and garbage collection. But since heap manger saves space otherwise we will have to fix size of activation at compile time, runtime overhead is the price worth it
  • 18. Sr no. Static allocation Stack allocation Heap allocation 1. Static Allocation is done for all data objects at compile time In stack allocation, stack is used to manage runtime In heap allocation, heap is used to manage dynamic memory allocation 2. Data structures can not be created dynamically as the amount of data storage required by each data object is determined by compiler Data structures and data objects can be created dynamically Data structures and data objects can be created dynamically
  • 19. Sr no. Static allocation Stack allocation Heap allocation 3. Memory allocation: The names of data objects are bound to storage at compile time. Memory allocation: Using ( LIFO ) activation records and data objects are pushed onto the stack. Memory addressing can be done using index and registers. Memory allocation: A contiguous block of memory from heap is allocated for activation record or data object . A linked list is maintained for free blocks.
  • 20. Access to non-local names Scope rules determine the treatment of non-local names. A common rule is lexical scoping or static scoping (most languages use lexical scoping). The scope rules of a language decide how to reference the non-local variables. .
  • 21. Access to non-local names  There are two methods that are commonly used : 1. Static or Lexical scoping : It determines the declaration that applies to a name by examining the program text alone. Ex :- Pascal, C and ADA. 2. Dynamic Scoping : It determines the declaration applicable to a name at run time by considering the current activations. Ex :- Lisp
  • 22. Access to non-local names Static or Lexical scoping Access Links  A direct implementation of lexical scope for nested procedures is obtained be adding a pointer called an access link to each activation record.  If procedure p is nested immediately within q in the source text, then the access link in an activation record for p points to the access link in the record for the most recent activation of q.
  • 23. Access to non-local names Static or Lexical scoping Displays  Faster access to non-locals than with access links can be obtained using an array d of pointers to activation records, called a display.  We maintain the display so that storage for a non- local a at nesting depth i is in the activation record pointed to by display element d [i].
  • 24. Access to non-local names Dynamic scoping Deep Access  Conceptually, dynamic scope results if access links point to the same activation records that control links do.  A simple implementation is to dispense with access links and use the control link to search into the stack, looking for the first activation record containing storage for the non-local name.  The term deep access comes from the fact that the search may go "deep" into the stack.
  • 25. Access to non-local names Dynamic scoping Shallow Access  Here the idea is to hold the current value of each name in statically allocated storage.  When a new activation of a procedure p occurs, a local name n in p takes over the storage statically allocated for n.  The previous value of n can be saved in the activation record for p and must be restored when the activation of p ends.
  • 26. Block Blocks can be nested The property is referred to as block structured Blocks are simpler to handle than procedures
  • 27. Block  Blocks can be nested.  The property is referred to as block structured.  Blocks are simpler to handle than procedures  Blocks can be treated as parameter less procedures  Use stack for memory allocation  Allocate space for complete procedure body at one time
  • 28. Block  Scope of the declaration is given by most closely nested rule • The scope of a declaration in block B includes B • If a name X is not declared in B then an occurrence of X is in the scope of declarator X in B ' such that o B ' has a declaration of X o B ' is most closely nested around B
  • 29. Block  There are two methods of implementing block structure : 1. Stack Allocation : This is based on the observation that scope of a declaration does not extend outside the block in which it appears, the space for declared name can be allocated when the block is entered and de-allocated when controls leave the block. The view treat block as a “parameter less procedure” called only from the point just before the block and returning only to the point just before the block.
  • 30. Block  There are two methods of implementing block structure : 2. Complete Allocation : Here you allocate the complete memory at one time. If there are blocks within the procedure, then allowance is made for the storage needed for declarations within the books. If two variables are never alive at the same time and are at same depth they can be assigned same storage.
  • 31. Activation Record The activation record is a block of memory used for managing information needed by a single execution of procedure FORTRAN uses the static data area to store the activation record where as in PASCAL and C the activation record is situated in stack area
  • 32. Activation record  information needed by a single execution of a procedure is managed using activation record or frame: • Not all compilers use all of the fields • Pascal and C push activation record on the run time stack when procedure is called and pop the activation record off the stack when control returns to the caller
  • 33. Activation record 1. Temporary values :- Arising in the evaluation of expression 2. Local data :- Data that is local to the execution of the procedure 3. Saved machine status :- State of the machine info before procedure is called. Values of program counter and machine registers that have to be restored when control returns from the procedure .
  • 34. Activation record 4. Access links :- refers non local data held in other activation records. 5. Control link :- points to the activation record of the caller. 6. Actual parameters :- used by the calling procedure to supply parameters to the called procedure . [ in practice these are passed in registers ] 7. Returned values :- used by the called procedures to return a value to the calling procedure. [ in practice it is returned in a register ]
  • 35. Activation record The activation call for factorial(3) EXAMPLE
  • 37. REFERENCES  www.slideshare.com  Aho, Sethi & Ullman, “Compilers: Principles, Techniques and Tools”, Pearson Education  V Raghvan, “Principles of Compiler Design”, TMH
  • 38. BY: THANK YOU VIVEK BHUSHAN TIWARI NILANSHI NIGAM ARJUN SRIVASTAVA ALANKAR MISHRA RIYA AGARWAL

Editor's Notes

  1. You can safely remove this slide. This slide design was provided by SlideModel.com – You can download more templates, shapes and elements for PowerPoint from http://slidemodel.com/