[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2161.0. "$MGBLSC on AXP problems" by GALVIA::MCCARTHY_M () Thu Apr 24 1997 07:43

    I am working on an Alpha migration project and my application depends
    on calls to $MGBLSC $DGBLSC and $CRMPSC, does any body know off hand
    of any problems that I may encounter with these calls on the Alpha.
    Some examples would help a lot.
    
    Thanks in advance 
    
    Mick
T.RTitleUserPersonal
Name
DateLines
2161.1Page sizeWIBBIN::NOYCEPulling weeds, pickin' stonesThu Apr 24 1997 09:2021
The only problem you will run into is that Alpha processors don't have
512-byte pages.  The Alpha architecture allows processors to have page
sizes of 8KB, 16KB, 32KB, or 64KB.  All existing Alpha processors (and all
currently-planned ones that I know of) have 8KB pages.  If you don't want
to port your code again, write it to do things in 64KB chunks (that's always
some number of whole Alpha pages), or use $GETSYI to find the page size of
the system you're currently running on.

If you were to try to remap, or delete, a piece of memory smaller than 8KB,
the data around it might get remapped or deletes along with it.  To protect
against this silent error, VMS added some restrictions for the INADR array
for these services.  On Alpha, the start address INADR[0] must be the first
byte of a page, and the end address INADR[1] must be the last byte of a page. 
(On VAX, you can simply name any byte in a page to indicate that page.)
I'm pretty sure this restriction doesn't apply if you're using SEC$M_EXPREG
for your CRMPSC or MGBLSC call.

One other peculiarity: If the file you're mapping isn't a multiple of 8KB
long, it's possible to create a page that only has backing store for the
first few 512-byte blocks.  Don't use the remainder of that page -- its
contents can vanish unpredictably.
2161.2GBLSEC.CXDELTA::HOFFMANSteve, OpenVMS EngineeringThu Apr 24 1997 12:32126
   If you can use V7.0 and later, mmap() is available.

:    I am working on an Alpha migration project and my application depends
:    on calls to $MGBLSC $DGBLSC and $CRMPSC, does any body know off hand
:    of any problems that I may encounter with these calls on the Alpha.
:    Some examples would help a lot.
   
   See the Programming Concepts manual, the VAX C to DEC C migration
   manual, and the Alpha porting manual (from V7.1).  Also see the
   OpenVMS VAX code you are porting.  And see the attached example:

#include <descrip.h>
#include <lib$routines.h>
#include <psldef.h>
#include <rms.h>
#include <secdef.h>
#include <ssdef.h>
#include <starlet.h>
#include <stdio.h>
#include <string.h>
#include <stsdef.h>
#include <unixlib.h>

#define MAXACCLEN 16

struct ItemList3
    {
    short int ItemLength;
    short int ItemCode;
    void *ItemBuffer;
    void *ItemRetLen;
    };
struct RmsFileContext
    {
    struct FAB fab;
    struct NAM nam;
    char rss[NAM$C_MAXRSS];
    short max_rec_siz;
    char *data_buffer;
    };
#define P0SPACE ((void*)0x0200)
#define BOGUSMAX 10

RmsFileOpen( struct FAB *fab, char *FileName, char *DefFileName )
    {
    int RetStat;

    *fab = cc$rms_fab;

    fab->fab$l_alq = 10;
    fab->fab$b_fac = 0;
    fab->fab$l_fop = FAB$M_UFO | FAB$M_CIF;
    fab->fab$b_shr = FAB$M_UPI | FAB$M_SHRPUT | FAB$M_SHRGET | FAB$M_SHRUPD;

    fab->fab$l_fna = FileName;
    fab->fab$b_fns = strlen( FileName );
    fab->fab$l_dna = DefFileName;
    fab->fab$b_dns = strlen( DefFileName );

    /*
    // Attempt to open the file...
    */
    RetStat = sys$create( fab, 0, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;

    return RetStat;
    }

main()
    {
    int RetStat;
    struct ItemList3 ItmLst[10];
    $DESCRIPTOR( SecDsc, "FACNAM_GLOBAL_SECTION_NAME" );
    int i;
    void *InAdr1[2] = {P0SPACE,P0SPACE};
    void *RetAdr1[2] = {NULL,NULL};
    void *InAdr2[2] = {P0SPACE,P0SPACE};
    void *RetAdr2[2] = {NULL,NULL};
    struct FAB Fab1, Fab2;
    struct insec
	{
	int Bogus[BOGUSMAX];
	} *Sec1, *Sec2;

    /*
    //	Create and open, and map the global section...
    */
    RetStat = RmsFileOpen( &Fab1, "BOGUS", "SYS$SCRATCH:.TMP" );
    if (!$VMS_STATUS_SUCCESS( RetStat ))
	lib$signal( RetStat );
    RetStat = sys$crmpsc( InAdr1, RetAdr1, PSL$C_USER, 
	SEC$M_EXPREG | SEC$M_WRT | SEC$M_DZRO | SEC$M_GBL,
	&SecDsc,
	0, 0, Fab1.fab$l_stv, 1, 0, 0, 0 );
    if (!$VMS_STATUS_SUCCESS( RetStat ))
	lib$signal( RetStat );

    /*
    //	Create and open, and map the global section again...
    */
    RetStat = RmsFileOpen( &Fab2, "BOGUS", "SYS$SCRATCH:.TMP" );
    if (!$VMS_STATUS_SUCCESS( RetStat ))
	lib$signal( RetStat );
    RetStat = sys$crmpsc( InAdr2, RetAdr2, PSL$C_USER, 
	SEC$M_EXPREG | SEC$M_WRT | SEC$M_GBL,
	&SecDsc,
	0, 0, Fab2.fab$l_stv, 1, 0, 0, 0 );
    if (!$VMS_STATUS_SUCCESS( RetStat ))
	lib$signal( RetStat );

    /*
    //	Write the information to one "window"...
    //	... read the data back from the other.
    */
    Sec1 = RetAdr1[0];
    Sec2 = RetAdr2[0];
    for ( i = 0; i < BOGUSMAX; i++)
	Sec1->Bogus[i] = i;
    for ( i = 0; i < BOGUSMAX; i++)
	printf( "Bogus[%d] = %d\n", i, Sec2->Bogus[i] );

    return SS$_NORMAL;
    }