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

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

565.0. "$CRMPSC and global sections in memory" by WJG::GUINEAU () Fri Sep 25 1987 19:47



I'm trying to use a global section to allow 2 processes to communicate.

I have 1 process which will create a global section and map it
to a data structure (SDL defined) in C.

Then it will spawn a subprocess which will map to the section
by name (gsdnam).

BAsically I want a chunk of memory, which both these processes reference
via the SDL structure names.

The problem I'm having is that $CRMPSC wants a channel number of some file???

Whats this for? I just want to access memory! No files.

I used the flags - SEC$M_GBL|SEC$M_DZRO|SEC$M_WRT



John
T.RTitleUserPersonal
Name
DateLines
565.1Here you go, in C even!UFP::MURPHYRick MurphyFri Sep 25 1987 21:3899
    Here's a C code fragment that does what you want. It performs the
    task using CRMPSC, but it creates a pagefile global section... you
    don't need a file or a channel to do this - the backing store is
    the pagefile. After the section is created, the other processes
    just map to it using MGBLSC calls.
    	-Rick

/*
 * First, the code that creates the section.
 * this stuff was ported from ULTRIX [It used shared memory].
 * the "KEY" is used to fabricate the name of the section.
 */

    tshmid = create_section (TKEY, &torps,
    		sizeof(struct torp) * MAXPLAYER * MAXTORP);

    if ((tshmid&1) != 1 ) {
	printf("Can't create torp section");
	exit (tshmid);
    }
/*
 * lots of other stuff elided..
 */
create_section(key, ptr, size)
/*
 * Create a global section. KEY is used to identify the section name.
 * PTR is the address of a pointer to the section.
 * SIZE is the size of the section in bytes.
 */
int	key;
int	*ptr;
int	size;
{
    int	descr[2];
    int inadr[2];
    int retadr[2];
    int status;
    int page_size;
    char    str[64];
/*
 * The section is normally a System, Writable, Pagefile section.
 */
    static sec_flags = SEC$M_GBL|SEC$M_EXPREG|SEC$M_WRT|
		SEC$M_SYSGBL|SEC$M_PAGFIL;

/*
 * build the section name from the key.
 * then build a string descriptor to point to it.
 */
    sprintf(str, "XTREK_%d",key);
    descr[0] = strlen(str);
    descr[1] = &str;
/*
 * calculate size in pages given the size on bytes.
 */
    if (size && 0x1FF)
	page_size = size/0x200 + 1;
    else
	page_size = size/0x200;

    inadr[0] = 0;
    inadr[1] = 0;

    status = sys$crmpsc (
		 inadr , 
		 retadr , 
		 0 , 
		 sec_flags , 
		 descr , 
		 0 , 
		 0 , 
		 0 , 
		 page_size , 
		 0 , 
		 0 , 
		 0 );
/*
 *  If nopriv, we're not able to create the system section;
 *  fall back to group.
 */
    if (status == SS$_NOPRIV) {
	sec_flags = SEC$M_GBL|SEC$M_EXPREG|SEC$M_WRT|SEC$M_PAGFIL;
	status = sys$crmpsc (
		 inadr , 
		 retadr , 
		 0 , 
		 sec_flags , 
		 descr , 
		 0 , 
		 0 , 
		 0 , 
		 page_size , 
		 0 , 
		 0 , 
		 0 );
    }
    *ptr = retadr[0];
    return(status);
}
565.2map section CREATEDWJG::GUINEAUMon Sep 28 1987 09:499

I see. So the file (channel) is used as backing store for the section.

Well, I don't need that! I needed just what Rick posted.

Thanks Rick!

John
565.3CLT::PPLRTLCLT::GILBERTBuilderFri Oct 23 1987 10:413
    You may find your problem simplified with the parallel processing
    routines that are in V5 of VMS.  There's a conference (of course),
    and a kit that runs on V4 systems.  Just press <Select>, ....