IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

calling subprogram 1million times


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anoopn1985

New User


Joined: 23 Apr 2007
Posts: 16
Location: tvm

PostPosted: Mon Jan 17, 2011 2:16 pm
Reply with quote

Hi,

Cobol driver program calling a subprogram 1million times. If we call the subprogram as static, will it improve performance a lot?
How dynamic call works, if we have 1million call statements? Will it load the load module into memory during each call? What are the difference between loading the load module and working storage memory allocation in static and dynamic calls?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jan 17, 2011 4:11 pm
Reply with quote

There is a link to manuals at the top of the page. Click on it, find the COBOL Programming Guide manual, and read section 4.1.3.4 titled Performance considerations of static and dynamic calls.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 17, 2011 4:48 pm
Reply with quote

Is this Batch or CICS?

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jan 17, 2011 5:19 pm
Reply with quote

A CICS program calling a subprogram a million times???

Oh, the mental image this gives me ... what a way to start a Monday!
Back to top
View user's profile Send private message
anoopn1985

New User


Joined: 23 Apr 2007
Posts: 16
Location: tvm

PostPosted: Mon Jan 17, 2011 5:29 pm
Reply with quote

this is batch. Can anyone help me on this?
Back to top
View user's profile Send private message
anoopn1985

New User


Joined: 23 Apr 2007
Posts: 16
Location: tvm

PostPosted: Mon Jan 17, 2011 5:36 pm
Reply with quote

I already gone through the manuals given but didn't get an exact answer. My question is if I have 1million calls to a subprogram, then which call is better, static or dynamic? Also how dynamic call works? Will it load program to memory each time?
Back to top
View user's profile Send private message
anoopn1985

New User


Joined: 23 Apr 2007
Posts: 16
Location: tvm

PostPosted: Mon Jan 17, 2011 5:46 pm
Reply with quote

Will dynamic call load the program into memory 1million times or onle 1 time?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 17, 2011 6:01 pm
Reply with quote

How the sub-program access is controlled by the main-program is via the Compile option DYNAM/NODYNAM.

If there are other sub-program's currently being called by the main-program, then the use of this option will have an affect on all other sub-programs.

When called DYNAMICALLY, the load module (sub-program) is fetched one time by the operating system and remains in memory until JOB/STEP termination or the main-program issues a CANCEL.

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jan 17, 2011 6:12 pm
Reply with quote

the manual gives you the answer. re-read.

if you only called the sub-program once, an argument could be made,
but a million times, no arguments. go dynamic.

keeps your load module size smaller.
easier to maintain the code.

and as Robert indicated: this better not be cics.

Bill,
I belive the dynam/nodynam options have to do with how a module is called.

if i am a mainprogram and I call 4 modules statically and 2 modules dynamically,
it does not matter what the dynam/nodynam option is for the mainprogram.

a CALL variable will always result in a dynamic CALL.
depending upon the compile/link edit options,
a CALL literal could be static or could be dynamic.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jan 17, 2011 6:20 pm
Reply with quote

Either you did not read the manual reference I cited, or you cannot understand plain written English -- I'm not sure which:
Quote:
4.1.3.4 Performance considerations of static and dynamic calls


Because a statically called program is link-edited into the same load module as the calling program, a static call is faster than a dynamic call. A static call is the preferred method if your application does not require the services of the dynamic call.
How did you NOT get an exact answer from this manual quote?
Quote:
How dynamic call works, if we have 1million call statements?
The same way if you have 1 call statement -- unless you use CANCEL.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 17, 2011 6:22 pm
Reply with quote

Thanks Dick. CRS must be kicking in. Plus, I haven't done Batch for quite some time so the rust is showing.... icon_wink.gif

Bill
Back to top
View user's profile Send private message
anoopn1985

New User


Joined: 23 Apr 2007
Posts: 16
Location: tvm

PostPosted: Mon Jan 17, 2011 6:58 pm
Reply with quote

Dick,

"if you only called the sub-program once, an argument could be made,
but a million times, no arguments. go dynamic. "

Here I'm confused. In static, there will be only one link-edited load for driver and subprograms and hence its faster. So if there is 1million calls, the static call will be effective rt? I agree that static will take more memory.
Also how the working storage memory is allocated in Dynamic calls? Will it allocate the subprogram memory seperately for each 1milloin calls?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jan 17, 2011 7:52 pm
Reply with quote

From section 4.1.3.2 of the COBOL Programming Guide manual (link at the top of the page):
Quote:
The first dynamic call to a subprogram within a run unit obtains a fresh copy of the subprogram. Subsequent calls to the same subprogram (by either the original caller or any other subprogram within the same run unit) result in a branch to the same copy of the subprogram in its last-used state, provided the subprogram does not possess the INITIAL attribute. Therefore, the reinitialization of either of the following items is your responsibility:


GO TO statements that have been altered

Data items
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Jan 18, 2011 5:15 am
Reply with quote

anoopn1985 wrote:
I agree that static will take more memory.

Static calls will not take more memory if you call every submodule at least once.

The advantage in memory usage with dynamic calls is for modules that you may conditionally call during execution. If they are not called, they don't have to be fetched.

Conditional calls will save some space in load libraries as every load module will not have to include the executable code.

On the other hand, dynamic calls will make it harder to cross reference module usage.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 18, 2011 12:52 pm
Reply with quote

Quote:
dynamic calls will make it harder to cross reference module usage.


standards allow for easy trapping/searching of calls.

CALL WS-DLC1932

would be a dynamic CALL to module DLC1932.

mapping for table driven dynamic calls
(where program name is contained in a db2 column)
can be easily generated using a db2 unload mechinism with SQL,
and then DFSORT/ICETOOL control statemens to parse and generate a cross listing.

I just finished a little pet-project where xrefs are created
(accurately, I may add)
purely with DB2 dumps and SUPERC results being parsed by DFSORT.
No cobol or rexx was necessary.
I had to create something that anyone could follow and execute the jobs.

but, agreed, static calls are much easier to cross-reference.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Jan 18, 2011 2:47 pm
Reply with quote

Just a correction of my own post...
Kjeld wrote:
Conditional calls will save some space in load libraries as every load module will not have to include the executable code.

Dynamic calls will save some space in load libraries as every load module will not have to include the executable code.

And I agree with Dick, proper standards can make x-referencing easier, but if legacy code is from different ages and organisations you might have to resolve calls on a module to module basis.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Jan 18, 2011 7:20 pm
Reply with quote

dbzTHEdinosauer wrote:
CALL WS-DLC1932

would be a dynamic CALL to module DLC1932.

While one might ASSUME that to be true, in actuality what you say would only be true if the variable named WS-DLC1932 contained the value 'DLC1932 ' at the time of the CALL.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Jan 18, 2011 8:14 pm
Reply with quote

That's where adherence to the programming standards comes in icon_cool.gif

The example can only be used if the call is unconditional: That call will only call that module. It could as well have been substituted with a static call.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Calling an Open C library function in... CICS 1
No new posts How to go into a subprogram in IBM De... IBM Tools 5
Search our Forums:

Back to Top