Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Heap and Linked List

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Wed Feb 20, 2013 12:48 pm    Post subject: Heap and Linked List
Reply with quote

Hi All,

I am using IBM routines for creating a Heap dynamically and then getting the storage for linkage variable.

Using CEECRHP, I get the Heap ID.

Using CEEGTST, and passing the Heap ID retrieved in the above step, I get the storage based on the length of my Linkage variable.


Q1. Can anyone please suggest if I need to get the Heap ID for every node that I create in the Linked List or is it ok for me to get the Heap ID once and then Perform my loop 'n'-times for n number of nodes to get the storage within that Heap?


Also is there any way where I can display all the nodes of my linked list using a single display?

Does the internal storage look as below? or is my understanding incorrect?

Quote:
Heap ID

Quote:
Linked List1

Anchor --> Node1(Data1+Next Address1) --> Node2(Data2+Next Address2) --> Node3(Data3+Next Address3) --> ... --> Node-n(Data-n+Next Address-n)


Quote:
Linked List2

Anchor --> Node1(Data1+Next Address1) --> Node2(Data2+Next Address2) --> Node3(Data3+Next Address3) --> ... --> Node-n(Data-n+Next Address-n)




Q2. Is is mandatory to use greater than or equal to 4096 in the HEAP-SIZE parameter of CEECRHP? Will it cause an error when my total size of all nodes is greater than size of the Heap?


Thanks
TS70363
Back to top
View user's profile Send private message

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Feb 20, 2013 2:06 pm    Post subject:
Reply with quote

The next manual will answer your questions :

z/OS Language Environment Programming Guide SA22-7561-05

Chapter 14 examples.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Wed Feb 20, 2013 3:13 pm    Post subject:
Reply with quote

Hi PeterHolland,

I had and again have gone thru the topics you have pointed in the above post. I am still unable to get answers to those specific questions which I have raised.

I would be thankful if you could please provide more details and inputs from ur end.

Thanks.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Feb 20, 2013 3:24 pm    Post subject:
Reply with quote

Quote:
Using CEECRHP, I get the Heap ID.


That is you want a new user heap.
Using HEAPID 0 gives you your standard heap.
In all calls to CEEGTST you supply the HEAPID.
So that will be the one obtained from CEECRHP or zero.
And if the total size of your nodes exceeds the heap size your
program will crash.
What more can I say?
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Wed Feb 20, 2013 3:36 pm    Post subject:
Reply with quote

Thank you for your reply.

Quote:
And if the total size of your nodes exceeds the heap size your
program will crash.


This implies that my program should be aware of the size of one node * number of nodes required to store all the data. I believe this will static and not dynamic. Or else should I call the CEECRHP with the MAX possible HEAP-SIZE?

and
Is there any way where I can display all the nodes of my linked list using a single display?[/quote]
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Feb 20, 2013 3:36 pm    Post subject: Reply to: Heap and Linked List
Reply with quote

You are making things more complicated than they should be .
You are mixing two <relatively unrelated> concepts

1) <some> linked list where each node storage is acquired using CEEGTST

2) in which HEAP acquire the storage

The HEAP is used to <isolate> the <getmains> according to some logic, usually the homogeneity of the sizes requested

Your program <might> work acquiring storage from the common heap

so depending on the logic You might ....

1) acquire the storage for each node/list in the <main> heap
2) acquire the storage for each node/list in a new heap ( one heap for all lists )
3) allocate a heap for each list

if the application is allocating and dropping lists the 3 approach might be better
no need free each node storage to drop the list, just free the heap

Quote:
Also is there any way where I can display all the nodes of my linked list using a single display?

pretty dumb question icon_cool.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Feb 20, 2013 3:41 pm    Post subject: Reply to: Heap and Linked List
Reply with quote

it is odd that somebody trying to use an advanced technique is not capable of reading and understanding the manuals itself

what is that You are not understanding here
( about the increment parameter ??? )
Quote:
z/OS: Language Environment Programming Reference
SA22-7562-09


CEECRHP lets you define additional heaps. It returns a unique heap_id. The heaps defined by CEECRHP can be used just like the initial heap (heap_id=0), below heap, and anywhere heap. Unlike the heaps created by these heap services, all heap elements within an additional heap can be quickly freed by a single call to CEEDSHP (discard heap).

The number of heaps supported by Language Environment is limited only by the amount of virtual storage available.

Syntax
>>-CEECRHP--(--heap_id--,--initial_size--,--increment--,-------->
>--options--,--fc--)-------------------------------------------><

heap_id (output)
A fullword binary signed integer. heap_id is the heap identifier of the created heap. If a new heap cannot be created, the value of heap_id remains undefined.
Storage obtained from heap_ids 79 and 80 is set to binary 0 independent of any initialization value specified by the STORAGE option.

initial_size (input)
A fullword binary signed integer. initial_size is the initial amount of storage, in bytes, allocated for the new heap. initial_size is rounded up to the nearest increment of 4096 bytes.
If initial_size is specified as 0, then the init_size specified in the HEAP run-time option is used. If no HEAP run-time option was provided and initial_size is specified as 0, CEECRHP uses the installation default.

increment (input)
A fullword binary signed integer. When it is necessary to enlarge the heap to satisfy an allocation request, increment represents the number of bytes by which the heap is extended. increment is rounded up to the nearest 4096 bytes.
If increment is specified as 0, then the incr_size specified in the HEAP run time option is used. If no HEAP run-time option was provided and increment equals 0, CEECRHP uses the installation default.

options (input)
A fullword binary signed integer. options are specified with the decimal codes as shown in Table 24.
Table 24. HEAP Attributes Based on the Setting of the options Parameter
Option Setting HEAP Attributes
00 Use same attributes as the initial heap (copy them from the HEAP run-time option)
01 HEAP(,,,FREE) (location inherited from HEAP run-time option)
70 HEAP(,,,KEEP) (location inherited from HEAP run-time option)
71 HEAP(,,ANYWHERE,KEEP)
72 HEAP(,,ANYWHERE,FREE)
73 HEAP(,,BELOW,KEEP)
74 HEAP(,,BELOW,FREE)
75 HEAP(,,ANYWHERE,) (disposition inherited from the HEAP run-time option)
76 HEAP(,,BELOW,) (disposition inherited from the HEAP run-time option)
77 HEAP(,,ANYWHERE,KEEP) (all heap storage obtained using this heap_id is allocated on a 4K boundary)
78 HEAP(,,ANYWHERE,FREE) (all heap storage obtained using this heap_id is allocated on a 4K boundary)
79 HEAP(,,ANYWHERE,KEEP) (all heap storage obtained using this heap_id is set to binary 0 when allocated using CEEGTST)
80 HEAP(,,ANYWHERE,FREE) (all heap storage obtained using this heap_id is set to binary 0 when allocated using CEEGTST)
fc (output)
A 12-byte feedback code, optional in some languages, that indicates the result of this service.
The following Feedback Codes can result from this service:

Code Severity Message number Message text
CEE000 0 — The service completed successfully.
CEE0P2 4 0802 Heap storage control information was damaged.
CEE0P4 3 0804 The initial size value supplied in a create heap request was unsupported.
CEE0P5 3 0805 The increment size value supplied in a create heap request was unsupported.
CEE0P6 3 0806 The options value supplied in a create heap request was unrecognized.
CEE0PD 3 0813 Insufficient storage was available to satisfy a get storage request.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Feb 20, 2013 3:48 pm    Post subject: Reply to: Heap and Linked List
Reply with quote

Quote:
Also is there any way where I can display all the nodes of my linked list using a single display?


not with the current Language Environment
IBM plans to implement a new cover function in place of all the existing functions

it will be called CEEPROPHET
it will do everything without being passed any parameter and ignoring the ones passed ( backwards compatibility )
, because it will know what the user wants without being told

You will have just to be patient and wait a bit
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Wed Feb 20, 2013 4:07 pm    Post subject:
Reply with quote

Thank you Enrico.

I had gone thru the same explanation before.
Quote:
And if the total size of your nodes exceeds the heap size your
program will crash.

According to what I understand the program will never abend, if I specify
Heap ID = 0
Initial size = 0
Increment = 0
Options = 0

and call CEECRHP. CEECRHP will use the installation default for initial size and for incrementing whenever required.

Quote:
so depending on the logic You might ....

1) acquire the storage for each node/list in the <main> heap
2) acquire the storage for each node/list in a new heap ( one heap for all lists )
3) allocate a heap for each list

I was planning to use the 2nd option but as suggested I will go ahead with the 3rd one -> 1 heap - 1 list as we need to free the heap after the read is successful in the next module.

TA.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Feb 20, 2013 4:15 pm    Post subject: Reply to: Heap and Linked List
Reply with quote

Quote:
According to what I understand the program will never abend, if I specify


NOPE, just try it

IMO to protect from an abed You will have to use Your own heap
specifyng an increment value ...

but be ready to use some workaround to avoid <storage trashing>
a programming error might cause an endless number of attempted heap extensions
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts reorder screeNS using SWAP LIST? mrsidhu12 TSO/ISPF 5 Thu Sep 01, 2016 2:19 pm
No new posts Getting list of tables defined under ... kishpra DB2 2 Wed Aug 24, 2016 10:36 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts how to find the duplicate list RAVIGUPTA1990 DB2 6 Wed Mar 30, 2016 12:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us