Block Structure | Non-Block Structure
Again Freestudy9 comes back with new post related to Block Structure | Non-Block Structure. Additionally, we had described it to a point to point Information.
Storage allocation can be done for two types of data variables.
1. Local data
2. Non-local data
- The local data can handle using activation record whereas non-local data can be handled using scope information.
- The block-structured storage allocation can do using static scope or lexical scope and the non-block structured storage allocation done using the dynamic scope.
- The local data can access with the help of activation record.
- The offset relative to base pointer of an activation record points to local data variables within a record, Hence
- Reference to any variable x in procedure = Base pointer pointing to start of procedure + Offset of variable x from base pointer.
Access to non-local names
- A procedure may sometimes refer to variables which are not local to it. Such variable called as non local variables. For the nonlocal names there two types of rules that can define: static and dynamic.
Static scope rule: Block Structure | Non-Block Structure
- The static scope rule also called as lexical scope. In this type, the scope determined by
examining the program text. PASCAL, C and ADA are the languages use the static scope
rule. These languages also called as block-structured language.
Dynamic scope rule: Block Structure | Non-Block Structure
- For non block structured languages, these dynamic scope allocation rules are used.
- The dynamic scope rule determines the scope of the declaration of the names at runtime by considering the current activation.
- LISP and SNOBOL are the languages which use dynamic scope rule.
Heap allocation: Block Structure | Non-Block Structure
- Moreover, Stack allocation strategy cannot use if either of the following is possible:
1. The value of local names must retain when activation ends.
2. A called activation outlives the caller.
- Heap allocation parcels out pieces of contiguous storage, as needed for activation record or other objects.
- Pieces may be de-allocated in any order, so over the time, the heap will consist of alternates allocated areas that free and in use.
- So, The record for an activation of procedure r retained when the activation ends procedure ends.
- So, Therefore, the record for new activation q(1, 9) cannot follow that for s physically.
- If the retained activation record for r deallocated, there will free space in the heap-allocated, between the activation records fo s and q.for