View previous topic :: View next topic
|
Author |
Message |
sats456
New User
Joined: 29 May 2005 Posts: 12
|
|
|
|
HI All,
Could anyone of you clear my confusion on the difference between Static V/S Dynamic Calls in COBOL.
Which one is better under what circumstances ?
1) Suppose I have a main program which calls 100 other programs (each one only once) which one would be better i.e Static or Dynamic Call ?
2) Similarly if I have a main program which calls a single program 100 times then in that case which one would be better i.e Static or Dynamic Call ?
Appreciate your quick feedback..
Regards,
Sats |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
While making decesion wheather to make satatic call or dynamic cal i think we can check if the size of the called program.If the called program is very small then we can go for static call, otherwise dynamic call will be better. As in static call, called program is embeded into calling programs load module.
In your first case since the number of called program is too high so it will be better to go for dynamic call, as if you go for static call and if any one of the 100 programs get changed then u need to compile all the 100 programs in correct sequence.
In second case what you have mentioned it is better to go for static call, as main rpogram is calling 100 times the subroutine program. As in dynamic call, control need to passed to different object module, so it will take more time, where as in static call there will be only one load module, so time consumption will be less in that case.
hope this will give a clear idea.Let us know if you have any concerns |
|
Back to top |
|
|
sats456
New User
Joined: 29 May 2005 Posts: 12
|
|
|
|
Kanak,
I really appreciate your quick & detailed response.Thanks for your Efforts.
I still had some doubts on first part of my Query.
Do you mean to say in case of Static Calls,The load module of all the called Programs will be embedded in the Load Module of the Main program.
Where as in case of Dynamic Calls,load Module of called program will be loaded into Main Memory as when the Program requires it and then later released.
Appreciate if you (or anybody ) could answer this..
Regards,
Sats |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
hi sats,
in static call, the object module is created seperately but while performing the link edit stpe only one laod module is generated.
where as in dynamic call, object module as well as load module both are different, that is why if you are calling program as dynamicaly you dopn't need to recompile the called program, if any modification is done in the called or mainline as it is decided in run time.
where as in static call, if called program is changed then you need to rebuild the load module again as static call embed the called program and calling program load module in a single load module.
Correct me if i am wrong.
Hope this clarify ur doubts. Let us know if you have any other query. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sats,
As is the case in most pgming choices one must evaluate the "tradeoffs" involved.
Statically linked modules:
accumulate virtual space on disk - bad. See Note 1 below
execute with a branch to the entry point - good (fast).
if 1 changes all must be relinked - bad.
Dynamically linked modules:
don't accumulate virtual space on disk - good.
execute with system assist & ohead - bad (slow). See Note 2 below.
if 1 changes only it must be relinked - good.
Note 1 - If main mod is 10K and each of the 100 subs is 5k the combined static load mod is 510K. The dynamic is 10K, but will use only 15K. As I recall you issue a CANCEL after each use of a submod to get a fresh copy of the code; if you need totals already accumulated, you'd want to avoid the CANCEL.
Note 2 - When each dynamic mod is CALLed memory is 1st searched for a useable copy. If none is found loadlib is searched and the mod is loaded (that means reads are done against the load PDS) and control is then passed to the called mod.
So it boils down to a process of evaluating the "tradeoffs" (good vs bad) and making a decision. Now you know why the ques was posed as it was.
BTW, you said:
Quote: |
Appreciate your quick feedback. |
I assume this was an interview ques and the interview is over. Why the rush? No problem, Just curious. |
|
Back to top |
|
|
sats456
New User
Joined: 29 May 2005 Posts: 12
|
|
|
|
Thanks to you all..
All my Queries have been resolved now.
I really appreciate the efforts of everyone.
Regards,
Sats |
|
Back to top |
|
|
|