* Re: ULTRIX shared memory question...
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.
0 siblings, 0 replies; 2+ messages in thread
From: Alan Rollow - Alan's Home for Wayward Tumbleweeds. @ 1993-01-06 18:47 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread