[comp.os.vms] Help Request

SY$LEE@CUCHEM.CHEM.COLUMBIA.EDU (TIM M. LEE) (07/08/87)

To All Kind Souls,

I am posting the following help message on the behalf of Professor Matt Vernon
in our department.  Please send mail to the following id on Bitnet.

Bitnet: ve$vernon@cuchem

Thanking all in advance,
Tim

----------------- HELP MSG --------------------------------------------------

PROBLEM: I HAVE A FORTRAN PROGRAM WHICH NEEDS TO HANDLE AN AST.
I WOULD LIKE TO LOCK IN MEMORY THE PAGES OF EITHER THE WHOLE PROGRAM OR 
MINIMALLY THOSE PARTS REQUIRED TO HANDLE THE AST (COMMON BLOCKS AND THE AST 
ROUTINE ITSELF) SO THAT THE RESPONSE TIME WILL BE QUICK. TO USE THE 
SYSTEM SERVICES LOCK PAGES IN MEMORY ROUTINE SYS$LCKPAG OR SYS$LKWSET
I NEED TO KNOW THE ADDRESSES OF THE PAGES TO BE LOCKED. I DO NOT KNOW HOW 
TO USE SYSTEM ROUTINES (SYS$GETJPI??) TO FIND THESE ADDRESSES.

ANY HELP WOULD BE APPRECIATED.

		THANKS

		Matt Vernon

carl@CITHEX.CALTECH.EDU (Carl J Lydick) (07/10/87)

 > PROBLEM:  I HAVE A FORTRAN PROGRAM WHICH NEEDS TO HANDLE AN AST.   I  WOULD
 > LIKE  TO  LOCK IN MEMORY THE PAGES OF EITHER THE WHOLE PROGRAM OR MINIMALLY
 > THOSE PARTS REQUIRED TO HANDLE THE AST (COMMON BLOCKS AND THE  AST  ROUTINE
 > ITSELF)  SO  THAT  THE  RESPONSE  TIME  WILL  BE  QUICK.  TO USE THE SYSTEM
 > SERVICES LOCK PAGES IN MEMORY ROUTINE SYS$LCKPAG OR SYS$LKWSET  I  NEED  TO
 > KNOW  THE  ADDRESSES  OF  THE PAGES TO BE LOCKED.  I DO NOT KNOW HOW TO USE
 > SYSTEM ROUTINES (SYS$GETJPI??) TO FIND THESE ADDRESSES.

Warning:  I've never used SYS$LCKPAG or SYS$LKWSET.   My  recommendations  may
well be useless.

However, I suspect your best bet will be to use the DCL ANALYZE/IMAGE  utility
to find out where the pages you want to lock reside (or you may be able to use
the compilation listing and link map to do it), after having put in your  call
to  the  system  service  using an arbitrary address (so that the code doesn't
move around when you put in the call).   Then  edit  the  source  to  use  the
addresses you find that way.

LEICHTER-JERRY@YALE.ARPA (07/11/87)

    PROBLEM: I HAVE A FORTRAN PROGRAM WHICH NEEDS TO HANDLE AN AST.
    I WOULD LIKE TO LOCK IN MEMORY THE PAGES OF EITHER THE WHOLE PROGRAM OR 
    MINIMALLY THOSE PARTS REQUIRED TO HANDLE THE AST (COMMON BLOCKS AND THE AST 
    ROUTINE ITSELF) SO THAT THE RESPONSE TIME WILL BE QUICK. TO USE THE 
    SYSTEM SERVICES LOCK PAGES IN MEMORY ROUTINE SYS$LCKPAG OR SYS$LKWSET
    I NEED TO KNOW THE ADDRESSES OF THE PAGES TO BE LOCKED. I DO NOT KNOW HOW 
    TO USE SYSTEM ROUTINES (SYS$GETJPI??) TO FIND THESE ADDRESSES.

The %LOC function allows you to obtain the address of a storage element, such
as a variable in a common block.  What you'd probably do is apply %LOC to a
pair of variables, one at the beginning of the common block, one at the end.

%LOC also works for external procedure names.  The problem here is, that
while the name of a function indicates where it begins, there is no real
indication of where it ends.  About the best you can do is use the address
of the next function defined in the same source file, with the knowledge that
there's probably no commitment anywhere that it is GUARANTEED to follow in
memory - though it's a pretty safe assumption.  (You have to make such assump-
tions because you are inherently mixing a low-level, machine-address interface
with a high-level compiler that assigns addresses outside of your control.
For variables in COMMON, the language definition lets you force the compiler
to use a particular ordering, but there is no analogous construct for code.)

							-- Jerry
-------

jeh@crash.CTS.COM (Jamie Hanrahan) (07/11/87)

In article <8707110230.AA28524@ucbvax.Berkeley.EDU>,
 <LEICHTER-JERRY@YALE.ARPA> writes:
>%LOC also works for external procedure names.  The problem here is, that
>while the name of a function indicates where it begins, there is no real
>indication of where it ends.  About the best you can do is use the address
>of the next function defined in the same source file, ...

VAX-11 FORTRAN supports the ENTRY statement, which allows you to
define an alternate entry point within a procedure (subroutine or
function).  Thus, you can ...

	INTEGER*4 FUNCTION LOCKED_FUNC (ARG, ...)
	-
	-
	(declarations, code, etc.)
	-
	-
	ENTRY LOCKED_FUNC_END (ARG, ...)
	END

Then, in your routine to lock the routine, just use %LOC(LOCKED_FUNC)
and %LOC(LOCKED_FUNC_END) to get the addresses of the beginning and
end of the procedure.

jeh@crash.CTS.COM (Jamie Hanrahan) (07/13/87)

In a private communication, Jerry Leichter writes: 
>     [In response to a comment of mine on the lack of any certain way of
>     determining the address of the END of a FORTRAN function, Mr. Hanrahan
>     writes:  ]
> >     VAX-11 FORTRAN supports the ENTRY statement ... Thus, you can ...
> >     
> >     	INTEGER*4 FUNCTION LOCKED_FUNC (ARG, ...)
> >     	-
> >     	-
> >     	(declarations, code, etc.)
> >     	-
> >     	-
> >     	ENTRY LOCKED_FUNC_END (ARG, ...)
> >     	END
> >     
> >     ... [and] use %LOC(LOCKED_FUNC) and %LOC(LOCKED_FUNC_END) to get the
> >     addresses of the beginning and end of the procedure.
> 
> Again, this will PROBABLY work, but there is NOTHING in any FORTRAN definition
> I know of that specifies where the code generated for an ENTRY statement will
> actually be placed.  The fact that control will enter the function just after
> the entry statement is irrelevant - the compiler can allocate the actual entry
> code anywhere it likes, then provide a branch to the appropriate point within
> the function. ...

Hot damn, he's right!  The trick of using %LOC on an ENTRY name came
from the DEC Ed. Svcs. handout for the "Programming VMS in VAX-11 Fortran/
Macro", ca. 1980... and I've never seen it fail... but I don't recall 
seeing anything in the "official" VAX Fortran doc. that guarantees 
ordering of ENTRY points.  

Well, here's a trick that will work:  Put the function to be locked in
a source file by itself.  Put another dummy function in another source
file.  Compile them independently to produce two separate object files.
Then use the Linker CLUSTER options command to specify the order in
which to read the two files.  

Sigh!

LEICHTER-JERRY@YALE.ARPA (07/17/87)

    [In response to a comment of mine on the lack of any certain way of
    determining the address of the END of a FORTRAN function, Mr. Hanrahan
    writes:  ]
    VAX-11 FORTRAN supports the ENTRY statement ... Thus, you can ...
    
    	INTEGER*4 FUNCTION LOCKED_FUNC (ARG, ...)
    	-
    	-
    	(declarations, code, etc.)
    	-
    	-
    	ENTRY LOCKED_FUNC_END (ARG, ...)
    	END
    
    ... [and] use %LOC(LOCKED_FUNC) and %LOC(LOCKED_FUNC_END) to get the
    addresses of the beginning and end of the procedure.

Again, this will PROBABLY work, but there is NOTHING in any FORTRAN definition
I know of that specifies where the code generated for an ENTRY statement will
actually be placed.  The fact that control will enter the function just after
the entry statement is irrelevant - the compiler can allocate the actual entry
code anywhere it likes, then provide a branch to the appropriate point within
the function.

Note that the compiler will, if it places the actual code for the ENTRY in
line, have to generate a branch around it.  If the ENTRY was inside a loop -
wierd, but certainly possible, even legal if the loop is constructed using
IF's and GOTO's rather than DO - moving the code out of line makes a lot of
sense.
							-- Jerry
----eli>