#include #include #include #include #include #include #include #include #include #include #define P0SPACE_start ((void*)0x0200) #define P0SPACE_end ((void*)(0x0200 + 128*512)) #define GBLSECMAX 10 /* // Open the specified file, using basic RMS calls... // (The FAB$M_UFO is typically used with backing storage files.) */ int 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 ); /* // Create or open the specified file -- it is created if // not found, else it is opened. (See the FAB$M_CIF bit.) */ return sys$create( fab, 0, 0 ); } main() { int RetStat; $DESCRIPTOR( SecDsc, "RRL$GBLSEC" ); int i; void *InAdr1[2] = {P0SPACE_start,P0SPACE_end}; void *RetAdr1[2] = {NULL,NULL}; void *InAdr2[2] = {P0SPACE_start,P0SPACE_end}; void *RetAdr2[2] = {NULL,NULL}; struct FAB Fab1, Fab2; struct SecStructDef { int Gblsec[GBLSECMAX]; } *Sec1, *Sec2; /* // Create and open, and then map the global section... */ RetStat = RmsFileOpen( &Fab1, "GBLSEC", ".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 then map the global section. Again. */ RetStat = RmsFileOpen( &Fab2, "GBLSEC", ".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 ); /* // Now that we have the file mapped twice, overlay a structure // onto the base address of each "window" into the section, and // write some data into one "window"... And then read the data // back in from the other "window". */ Sec1 = RetAdr1[0]; printf( "\n RetAdr1[0] = %p,RetAdr1[1] = %p\n",RetAdr1[0],RetAdr1[1]); Sec2 = RetAdr2[0]; printf( "\n RetAdr2[0] = %p,RetAdr2[1] = %p\n",RetAdr2[0],RetAdr2[1]); for ( i = 0; i < GBLSECMAX; i++) Sec1->Gblsec[i] = i; memset( Sec1->Gblsec,33, 5120); printf( "Sec1->Gblsec is located at %p\n", RetAdr1[0] ); for ( i = 0; i < GBLSECMAX; i++) printf( " Sec1->Gblsec[%d] = %d\n", i, Sec1->Gblsec[i] ); printf( "Sec2->Gblsec is located at %p\n", RetAdr2[0] ); for ( i = 0; i < GBLSECMAX; i++) printf( " Sec2->Gblsec[%d] = %d\n", i, Sec2->Gblsec[i] ); /* ** */ RetStat = sys$updsec (RetAdr1,0, PSL$C_EXEC, 0,0,0,0,0); if (!$VMS_STATUS_SUCCESS( RetStat )) lib$signal( RetStat ); sys$hiber(); return SS$_NORMAL; }