Article 4680 of vmsnet.internals:
rkoehler@csc.com (Robert Koehler) writes:

>ashleyb@devvax.mincom.oz.au wrote:
>:           I have some macro32 to code that I have been converting to C. Most
>: of this has gone well but I have run into two snags.
>:  One. How do I identify and pass to lkwset the range of pages of a program
>: I wish to lock into the working set (in C).

>Put all the pages into a cluster, who's starting and ending address you can
>identify, such as a global structure.

certainly the optimal approach.  however, i happen to already have
Actual Source Code to do what he asks, so i'll post it:


#include <stdio.h>
#include <psldef.h>
#include <starlet.h>
#include <lib$routines.h>
#if defined(__ALPHA)
#  include <pdscdef.h>
#endif

typedef struct {
    void *beg;
    void *end;
} LockAddrs;

void LockWSPages(
    int locking,        /* lock if TRUE, unlock if FALSE */
    int linkagePair,    /* TRUE only if the range refers to a function under ALPHA */
    LockAddrs *therange
)
{
    unsigned long cv0;
    int (*fncptr)(LockAddrs *, LockAddrs *, unsigned long);

    if (therange != NULL && therange->beg != NULL && therange->end != NULL) {
        fncptr = (locking) ? sys$lkwset : sys$ulwset;
        cv0 = (*fncptr)(therange, NULL, PSL$C_KERNEL);
        if ((cv0 & 1) == 0) {
            lib$signal(cv0, 0);
        }
        /* under AXP/VMS, the addresses of functions are really just the "linkage pair"
         * and although they certainly need to be locked in for the target to be called later,
         * it would be nice to lock down the actual instructions ;-)
         */
#if defined(__ALPHA)
        if (linkagePair) {
            LockAddrs codeaddr;
            struct lkpdef *beglink;
            struct lkpdef *endlink;
            beglink = (struct lkpdef *) therange->beg;
            endlink = (struct lkpdef *) therange->end;
            codeaddr.beg = (void *) beglink->lkp$q_proc_value[0];
            codeaddr.end = (void *) endlink->lkp$q_proc_value[0];
            LockWSPages(locking, FALSE, &codeaddr);
        }
#endif
    }

    return;
}

i'll be happy to answer any questions.

ok
dpm
-- 
David P. Murphy                 mailto:murphy@connor.datametrics.com     (work)
systems programmer              mailto:dpm@access.digex.net          (personal)
                                http://www.access.digex.net/~dpm
COGITO ERGO DISCLAIMUM           ftp://ftp.access.digex.net/pub/access/dpm


