Last week I learnt something new & want to share it and also clear my doubt.
Now a cobol program designed to use both above & below the 16MB line memory will(may?) have problem calling a cobol program which is designed to use only memory below the 16MB line.I found its true only when your sub programs are dynamically called.In case of static call,there will be no addressing issue.
I had a main program compiled with[DATA(31),RENT,RMODE(AUTO),NODYNAM] statically calls a subprogram[call 'literal']
compiled with[DATA(24),RENT,RMODE(24)] without any issue.Now per above compiler options dynamic storage for main program will be above the line & for called program below the line.So, my job should abend while calling the subprogram.But the job runs ok when the call is static only abends when it is dynamic.
So my question is, in this scenario where will be dynamic storage allocated for both calling & called programs.
If it is below the line then can I conclude that while compiling any cobol program the COBOL compiler also checks what are the module it calls & their compilation options or something similar happens.
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
A Statically-Called sub-program always takes on the characteristics of the Caller and this is why you do not experience a S0C4, as the entire load module of the Caller and sub-program are one module.
A Dynamically-Called sub-program (Data (24)), will raise a S0C4 while attempting to address 31-Bit parm-data passed by the Caller, as the sub-program does not take on the caller's characteristics (as opposed to a static call), making the sub-program's characteristics independent of the caller's. Keep in mind if the caller was passing 24-Bit parm-data, the sub-program would be able to address this, regardless whether it was 24-Bit or 31-Bit.
To make a long story short, 24-Bit programs cannot address 31-Bit data.
the entire load module of the Caller and sub-program are one module
so the single load module will be allocated over 16MB line taking caller's attribute.right?
Next question is where the dynamic storage would be allocated for both programs & would that be a one single memory area for both programs or separate area?
I read somewhere in IBM manual if your program is compiled with RENT then the load module & the working storage would acquire separate storage and location of working storage depends on DATA option.
In my case, as my caller & called program are compiled with RENT, so both caller & called program's working storage would be separate to their load module.Now, where it will be allocated over or below the line?Since it is passing data successfully in static calls I assume that both are in the same region[either above or below the line]
Joined: 06 Jun 2008 Posts: 8479 Location: Dubuque, Iowa, USA
From the Enterprise COBOL Programming Guide manual, section 1.2.6 Storage and its Addressability:
Addressing mode (AMODE) is the attribute that tells which hardware addressing mode is supported by your program: 24-bit addressing, 31-bit addressing, or either 24-bit or 31-bit addressing. This attribute is AMODE 24, AMODE 31, or AMODE ANY, respectively. The object program, the load module, and the executing program each has an AMODE attribute. All Enterprise COBOL object programs are AMODE ANY.
Residency mode (RMODE) is the attribute of a program load module that identifies where in virtual storage the program will reside: below the 16-MB line, or either below or above. This attribute is RMODE 24 or RMODE ANY.
You will also want to read 18.104.22.168.2 When to use a dynamic call with subprograms in the same manual.
Also you need to know that the linkage editor / binder is the FINAL arbiter on AMODE and RMODE and hence you need to review the linkage editor / binder output, not just the compiler output, to determine the final AMODE and RMODE. From 2.4.44 RENT in the same manual:
DATA and RMODE settings: The RENT option interacts with other compiler options that affect storage and its addressability. When a reentrant program is to be run with extended addressing, you can use the DATA(24|31) option to control whether dynamic data areas are allocated in unrestricted storage or in storage obtained from below 16 MB. Compile programs with RENT or RMODE(ANY) if they will be run with extended addressing in virtual storage addresses above 16 MB.
To summarize: the interactions between the various compile options, as well as linkage editor / binder options, is complex and not always intuitive.