From: alan@nabeth.enet.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
Subject: Re: ULTRIX shared memory question...
Date: Wed, 6 Jan 1993 18:47:43 GMT [thread overview]
Message-ID: <1993Jan6.184743.14999@nntpd2.cxo.dec.com> (raw)
In-Reply-To: 1993Jan5.142908.19896@icf.hrb.com
In article <1993Jan5.142908.19896@icf.hrb.com>, dbd@icf.hrb.com (Douglas B. Dodson) writes:
>Hello,
>
>I am in need of some information on shared memory for ULTRIX systems. I am
>working on a DECStation 5000/240 running ULTRIX and would like to set up a
>group of variables which will be used by up to five separate processes. The
>processes would be able to read as well as modify the variables. This is
>something similar to using global sections in VMS but I can't find much
>information on doing it with ULTRIX. Thanks to anyone who can help me out.
The manual pages ftok(3), shmop(2), shmctl(2) and shmget(2) are the ones
of interest. You may also want a semaphore to control access to the
memory. Replace the "shm" with "sem" for those manual pages. I don't
if there is any programming documentation on how to use these in the
doc set. You probably find a text that explains UNIX System V shared
memory that will do.
Roughly, you want to do something like this:
1. Create the section of shared memory. You can either do this
as a seperate program, or have any invocation of the program
create it if it doesn't exist.
key = ftok(path, id) ;
shmid = shmget(key, size, shmflag | IPC_CREAT) ;
/*
* If you want to initialize it first.
*/
address = shmat(shmid, shmadr, shmflag) ;
/*
* Detach.
*/
shmdt(address) ;
2. To use it, assuming that it is created.
key = ftok(path, id) ;
shmid = shmget(key, size, shmflag) ;
address = shmat(shmid, ...) ;
shmdt(address); /* when done */
>
> - Doug -
>
>--
>Douglas B. Dodson Internet: DBD@ICF.HRB.COM
>
--
Alan Rollow alan@nabeth.cxo.dec.com
prev parent reply other threads:[~1993-01-06 18:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-01-05 19:29 ULTRIX shared memory question Douglas B. Dodson
1993-01-06 18:47 ` Alan Rollow - Alan's Home for Wayward Tumbleweeds. [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox