home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / dec / 6711 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.2 KB  |  71 lines

  1. Newsgroups: comp.sys.dec
  2. Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nabeth!alan
  3. From: alan@nabeth.enet.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
  4. Subject: Re: ULTRIX shared memory question...
  5. Message-ID: <1993Jan6.184743.14999@nntpd2.cxo.dec.com>
  6. Lines: 58
  7. Sender: alan@nabeth (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
  8. Reply-To: alan@nabeth.enet.dec.com (Alan Rollow - Alan's Home for Wayward Tumbleweeds.)
  9. Organization: Digital Equipment Corporation
  10. References:  <1993Jan5.142908.19896@icf.hrb.com>
  11. Date: Wed, 6 Jan 1993 18:47:43 GMT
  12.  
  13.  
  14. In article <1993Jan5.142908.19896@icf.hrb.com>, dbd@icf.hrb.com (Douglas B. Dodson) writes:
  15. >Hello,
  16. >
  17. >I am in need of some information on shared memory for ULTRIX systems.  I am
  18. >working on a DECStation 5000/240 running ULTRIX and would like to set up a
  19. >group of variables which will be used by up to five separate processes.  The
  20. >processes would be able to read as well as modify the variables.  This is
  21. >something similar to using global sections in VMS but I can't find much
  22. >information on doing it with ULTRIX.  Thanks to anyone who can help me out.
  23.  
  24. The manual pages ftok(3), shmop(2), shmctl(2) and shmget(2) are the ones
  25. of interest.  You may also want a semaphore to control access to the
  26. memory.  Replace the "shm" with "sem" for those manual pages.  I don't
  27. if there is any programming documentation on how to use these in the
  28. doc set.  You probably find a text that explains UNIX System V shared
  29. memory that will do.
  30.  
  31. Roughly, you want to do something like this:
  32.  
  33. 1.  Create the section of shared memory.  You can either do this
  34.     as a seperate program, or have any invocation of the program
  35.     create it if it doesn't exist.
  36.  
  37.     key = ftok(path, id) ;
  38.  
  39.     shmid = shmget(key, size, shmflag | IPC_CREAT) ;
  40.  
  41.     /*
  42.      *    If you want to initialize it first.
  43.      */
  44.     address = shmat(shmid, shmadr, shmflag) ;
  45.  
  46.     /*
  47.      *    Detach.
  48.      */
  49.     shmdt(address) ;
  50.  
  51. 2.  To use it, assuming that it is created.
  52.  
  53.     key = ftok(path, id) ;
  54.  
  55.     shmid = shmget(key, size, shmflag) ;
  56.  
  57.     address = shmat(shmid, ...) ;
  58.  
  59.     shmdt(address); /* when done */
  60.  
  61.     
  62. >
  63. >                        - Doug -
  64. >
  65. >-- 
  66. >Douglas B. Dodson             Internet:    DBD@ICF.HRB.COM
  67. >
  68. --
  69. Alan Rollow                alan@nabeth.cxo.dec.com
  70.  
  71.