devil@techunix.BITNET (Gil Tene) (03/22/90)
Hello netland..., I am doing some work on a Sun, under SonOS 4.0.3, using the System V shared memory interface. I have succesfully mapped and used shared memory several times. I am trying to solve the following problem: I have one process creating a shared image of both data and data pointers, and I would like the pointers in the shared data pointers map to point to the correct data address in all processes, mapping the data and the data pointers is easy, but since mapping (using shmat) is usually done to a "randomly" selected virtual address in every process, meaning that they get trough ok, but don't point to the data. I am trying to avoid using "relative" pointers , i.e. index from data table start, since speed is of crucial importance in my application. I am aware of the fact that shmat() accepts a paddress argument, telling it where to map the shared memory to (in the process virtual address space). My problem is : How do i "allocate" a specific area in process virtual space, in order to map the shared memory into it. How can i specify this virtual process address as a constant, and where do i take it from (top of user vir. address space, etc.). Allocating using sbrk() or malloc() variaties, doesn't give me any way to control the exact address of the allocated block... I am trying to avoid the criminal act of assuming that all my processes have a virtual address space smaller than some constant, and mapping to an address above it. What I am looking for is a system call that hides this act. I would apreciate any help on this subject, and will summerize e-mail responses to the net.... Thanks in advance... Gil Tene. devil@techunix.technion.ac.il devil@techunix.BITNET
cpcahil@virtech.uucp (Conor P. Cahill) (03/23/90)
In article <9464@discus.technion.ac.il> devil%techunix.bitnet@jade.berkeley.edu (Gil Tene) writes: >My problem is : How do i "allocate" a specific area in process virtual space, >in order to map the shared memory into it. How can i specify this virtual >process address as a constant, and where do i take it from (top of user >vir. address space, etc.). Allocating using sbrk() or malloc() variaties, >doesn't give me any way to control the exact address of the allocated block... Pulling an old response out of the saved bucket: From cpcahil Wed Nov 1 09:37:04 1989 Path: virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Shared memory and pointers Message-ID: <1989Nov1.143704.9258@virtech.uucp> Date: 1 Nov 89 14:37:04 GMT References: <525@wizard.UUCP> Distribution: usa Organization: Virtual Technologies Inc. Lines: 24 In article <525@wizard.UUCP>, john@wizard.UUCP (John Danner) writes: > group, neither of which are very clean. First, make sure that every client > maps each block of shared memory to the same location. Second, replace > pointers with something like objectID's and keep a table on the server which > has block #'s and offsets for each objectID. I have seen 2 solutions to these problems. 1. have the first program that creates the shared memory segment attach it at whatever address it determins is appropriate and then writes said address into the first 4 bytes of the shared memory segment itself. All follow on program will attach the segment at the default address, read the address that it should be attached at, detach it, and finally re-attach it at the appropriate address. 2. keep track of data using relative pointers (offset from the begining of the shared memory segment) this is a real bear. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170