Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Difference between satic and controlled storage clss in PL1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
umamageswari

New User


Joined: 26 Apr 2005
Posts: 1

PostPosted: Tue Apr 26, 2005 12:31 pm    Post subject: Difference between satic and controlled storage clss in PL1
Reply with quote

Hi,
could any1 help me in bringing the Difference between satic and controlled storage clss in PL1.
Many thanks
Back to top
View user's profile Send private message

NitinD

New User


Joined: 03 May 2005
Posts: 3

PostPosted: Thu May 05, 2005 4:20 pm    Post subject:
Reply with quote

Static Storage
Variables declared with the STATIC attribute are allocated prior to running a program. They remain allocated until the program terminates.


In the following example, the variable X is allocated for the life of the program, but it can be referenced only within procedure B or any block contained in B. The variable Y gets the STATIC attribute and is also allocated for the life of the program.

dcl Y char(1?);
A: proc options(main);
B: proc;
declare X static internal;
end B;
end A;
C: proc;
Y = 'hello';
end C;

Controlled storage
Variables declared as CONTROLLED are allocated only when you specify them in an ALLOCATE statement. A controlled variable remains allocated until a FREE statement that names the variable is encountered or until the end of the program.
Controlled variables are partially independent of the program block structure, but not completely. The scope of a controlled variable can be internal or external.
When it is declared as internal, the scope of the variable is the block in which the variable is declared and any contained blocks. Any reference to a controlled variable that is not allocated is in error.


In the following example, the variable X can be validly referred to within procedure B
and that part of procedure A that follows execution of the CALL statement.

A: proc;
dcl X controlled;
call B;
...
B: proc;
allocate X;
...
end B;
end A;
Generally, controlled variables are useful when a program requires large data aggregates with adjustable extents.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Fri Jun 17, 2005 10:14 am    Post subject: Re: Difference between satic and controlled storage clss in
Reply with quote

Static Storage:
Whenever the value of a variable must be saved between different invocations of the same procedure, storage for that variable has to be allocated statically. The storage is allocated before execution of the program and remains allocated throughout the entire execution of the program. Static variables are initialized only once - before execution of a program begins. They are established with their respective values at a compile time.
Eg :

DCL 1 STRUCTURE STATIC,
2 A FIXED DECIMAL(5,2),
2 B FIXED DECIMAL(5,2);
DCL TABLE(100) CHAR(10) STATIC;

Controlled Storage :
It is used to create a stack. The storage of controlled variables is allocated in the program by the ALLOCATE statement and released by the FREE statement.
Eg.
DCL A(100) FIXED DECIMAL(5) CONTROLLED;
ALLOCATE A;
GET LIST(A);
TOTAL = SUM(A);
FREE A;
A variable that has the CONTROLLED attribute is allocated upon the execution of an ALLOCATE statement specifying that identifier name. This allocation remains in effect even after the termination of the block in which it is allocated. Storage remains allocated until the execution of a FREE statement in which the identifier name is specified. The ALLOCATE statement may also be used to specify the amount of storage required for arrays if the array size is to be established during program execution rather than at compile time.
Eg :
DCL ARRAY(*,*) FIXED DECIMAL(5) CONTROLLED;
GET LIST(I,J);
ALLOCATE ARRAY(I,J);
Here * is used to indicate number of dimensions.
Back to top
View user's profile Send private message
sudheer648

New User


Joined: 23 May 2005
Posts: 97
Location: Chennai

PostPosted: Fri Jun 17, 2005 3:26 pm    Post subject: Re: Difference between satic and controlled storage clss in
Reply with quote

Hi Pramella,

1.If there is no associate Free Statement for an Allocate Statement in the Program the memory allocated will be freed after the end of the program or not

2.Because language doesnt any gargabe collector to remove all the dangling memory pointers.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Fri Jun 17, 2005 4:10 pm    Post subject: Re: Difference between satic and controlled storage clss in
Reply with quote

Hi sudheer,

At the end of a program the allocated memory will get released. Consider an example :
I allocate x;
-
-
II allocate x;
-
-
If you want to access the firstly allocated x variable in the middle of the program unless and otherwise you release the memory storage of the secondly allocated x variable you cannot use the firstly allocated x variable since it is a stack (last in first out). Correct me if i am wrong.

Regards.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sharing PLI storage Pedro PL/I & Assembler 2 Mon Oct 16, 2017 10:11 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Iterative use of a REXX script causin... bryonyh CLIST & REXX 4 Fri Jul 28, 2017 12:52 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us