home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.dec
- Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nabeth!alan
- From: alan@nabeth.enet.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
- Subject: Re: ULTRIX shared memory question...
- Message-ID: <1993Jan6.184743.14999@nntpd2.cxo.dec.com>
- Lines: 58
- Sender: alan@nabeth (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
- Reply-To: alan@nabeth.enet.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
- Organization: Digital Equipment Corporation
- References: <1993Jan5.142908.19896@icf.hrb.com>
- Date: Wed, 6 Jan 1993 18:47:43 GMT
-
-
- 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
-
-