Mapping Virtual address spaces

MACKINNON, BRYAN mackinnon at fnda20.fnal.gov
Sat Mar 9 06:34:08 AEST 1991


We have a (hopefully simple) problem that our lack of knowledge of UNIX
prevents us from solving. 

We need to have two processes map to the same data structure.  The data 
structure must be statically allocated at compile or link time.  I include
here some small code segements (both in fortran and c):

	PROGRAM A
	COMMON /XYZ/ MEM
	INTEGER*4 MEM
	MEM = 5
	-- code here to wait --
	END

	PROGRAM B
	COMMON /XYZ/ MEM
	INTEGER*4 MEM
	-- code here to wait for A to set MEM --
C	Mem should now contain 5 set by program A.
	TYPE *,MEM
	END

/* C code (obviously) */

int mem;

/* Program A. */

main()
  {
  mem = 5;
  -- code here to wait --
  }

/* Program B */

int mem;

main()
  {
  -- code to wait for A --
  printf("%d\n", mem);   /* mem should now contain 5. */
  }

In other operating systems (e.g. VMS), program A and B could call a system
service routine that would coerce the virtual address space so that, as far as
the CPU is concerned, "mem" resides at the same physical address in both
processes (even when the virtual address of "mem" is resolved before run time).
This is important since (for other reasons) we cannot dynamically allocate
"mem".  How would one do this in Unix (both BSD and System V).

-- Thanks, Bryan.

+--------------------------+------------------------------------------------+ 
| Bryan MacKinnon          | DECNET:   FNAL::MACKINNON	      	            | 
| Computing Division/WH8E  | Internet: MACKINNON at BISON.FNAL.GOV             |
| Fermilab                 | Bitnet:   MACKINNO at FNAL.GOV		    | 
| Batavia IL 60510 USA     | Phone:    (708) 840-4790 / FAX: (708) 840-2783 !
+--------------------------+------------------------------------------------+ 
| "An oyster is only slightly more intelligent than a scientist."	    | 
|                                              - Mark Twain                 | 
+---------------------------------------------------------------------------+ 



More information about the Comp.unix.wizards mailing list