home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / ada / 3808 < prev    next >
Encoding:
Text File  |  1992-12-23  |  2.7 KB  |  92 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!lobster!nuchat!leeweyr!bill
  3. From: bill@leeweyr.sccsi.com (Bill Lee)
  4. Subject: Using Shared memory from Ada code.
  5. Message-ID: <1992Dec23.040144.7581@leeweyr.sccsi.com>
  6. Organization: Lee Aerie
  7. Date: Wed, 23 Dec 1992 04:01:44 GMT
  8. Lines: 82
  9.  
  10.  
  11. I have a couple of questions needing serious answers.
  12.  
  13. First question:
  14.  
  15. At work, we are developing a rather large, near-realtime application
  16. in Ada.  The application will consist of several processes (POSIX
  17. environment eventually, UNIX for the time being) with shared memory
  18. to be attached among all of the processes.
  19.  
  20. I have read an early version of Ted Baker's report which served as
  21. the basis for the 1003.20 efforts. In that paper, Ted has the
  22. following comments concerning shared memory:
  23.  
  24. "...There is uncertainty about whether the compiler will generate code that
  25.  reads and writes data through to memory. In the absence of pragmas specifying
  26.  otherwise, ... there is no guarantee that a reference or assignment to a 
  27.  shared memory object in the Ada source code will result in a compiler 
  28.  generating actual read or write operations to memory......"
  29.  
  30. O.k, the question: How do I use shared memory in my Ada programs
  31. so that the above concerns are mitigated? How do I make SURE that
  32. every reference to a shared memory object actually uses the shared
  33. memory?
  34.  
  35.  
  36.  
  37. Second question:
  38.  
  39. In the 1003.20 Ada binding we get functions which return System.Address
  40. values.  I want to put an Ada object at the address so that all
  41. future references to the object are actually referencing the shared
  42. memory. How?
  43.  
  44. I would like something like the following to work (perhaps it will, the 
  45. DEC Ada compiler swallowed it!):
  46.  
  47. --------------------------------------------------------------------------------
  48. with System;
  49. procedure Test is
  50.  
  51.   type Structures is
  52.     record
  53.       Name: string(1..20);
  54.       Status : boolean := false;
  55.     end record;
  56.   type Structure_Lists is array (integer range <> ) of Structures;
  57.  
  58.   Shared_Mem_Address : System.address;
  59.   List_Length : constant integer := 100;
  60.   The_List : Structure_Lists(1..List_Length);
  61.  
  62.  
  63.   function Attach ( An_Address : in System.address;
  64.                     Length     : in integer ) return Structure_Lists is
  65.     A_List : Structure_Lists ( 1..Length);
  66.     for A_List use at An_Address;
  67.   begin
  68.     return A_List;
  69.   end Attach;
  70.  
  71. begin
  72.           .
  73.         .
  74.     -- Somehow get a shared memory address into Shared_Mem_Address
  75.   The_List := Attach ( Shared_Mem_Address, List_Length );
  76.         .
  77.         .
  78.   The_List(Index).Status := true;
  79.         .
  80.         .
  81.     -- and so forth
  82. end Test;
  83. --------------------------------------------------------------------------------
  84.   
  85. The question can be simply put: how do I put an Ada object at an address
  86. in shared memory?
  87.  
  88.  
  89. Regards,
  90.  
  91. Bill Lee
  92.