Shared memory between process - Unix

This is a discussion on Shared memory between process - Unix ; Hello, Exists any way of creating a shared memory (or any other similary functionality) that can be accessed by more than one process? if yes what are the required functions in c/c++. I only required that one process writes and ...

+ Reply to Thread
Results 1 to 13 of 13

Thread: Shared memory between process

  1. Shared memory between process

    Hello,

    Exists any way of creating a shared memory (or any other similary
    functionality) that can be accessed by more than one process? if yes
    what are the required functions in c/c++. I only required that one
    process writes and all the others read the information writed by the
    first one.

    Nuno


  2. Re: Shared memory between process

    Nuno wrote:
    > Hello,
    >
    > Exists any way of creating a shared memory (or any other similary
    > functionality) that can be accessed by more than one process? if yes
    > what are the required functions in c/c++. I only required that one
    > process writes and all the others read the information writed by the
    > first one.
    >

    Use shared memory, see shmget and friends.

    --
    Ian Collins.

  3. Re: Shared memory between process

    On Apr 11, 2:01 am, "Nuno" wrote:

    > Exists any way of creating a shared memory (or any other similary
    > functionality) that can be accessed by more than one process? if yes
    > what are the required functions in c/c++. I only required that one
    > process writes and all the others read the information writed by the
    > first one.


    man shm_open



  4. Re: Shared memory between process

    In article <1176253289.256687.213950@y5g2000hsa.googlegroups.c om>,
    "Nuno" wrote:

    > Hello,
    >
    > Exists any way of creating a shared memory (or any other similary
    > functionality) that can be accessed by more than one process?


    Of course. If it couldn't be accessed by more than one process, it
    wouldn't make sense to call it "shared memory", would it?

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  5. Re: Shared memory between process

    Nuno wrote:
    > Hello,
    >
    > Exists any way of creating a shared memory (or any other similary
    > functionality) that can be accessed by more than one process? if yes
    > what are the required functions in c/c++. I only required that one
    > process writes and all the others read the information writed by the
    > first one.


    man mmap

    I find this is better than shmget.

  6. Re: Shared memory between process

    Thanks for the replys, help a lot.

    For someone that are trying to do the same and need an example here is
    a good simple example on how to do it:
    http://www.codemaestro.com/reviews/review00000107.html

    Nuno


    Gianni Mariani escreveu:
    > Nuno wrote:
    > > Hello,
    > >
    > > Exists any way of creating a shared memory (or any other similary
    > > functionality) that can be accessed by more than one process? if yes
    > > what are the required functions in c/c++. I only required that one
    > > process writes and all the others read the information writed by the
    > > first one.

    >
    > man mmap
    >
    > I find this is better than shmget.



  7. Re: Shared memory between process

    >> Exists any way of creating a shared memory (or any other similary
    >> functionality) that can be accessed by more than one process? if yes
    >> what are the required functions in c/c++. I only required that one
    >> process writes and all the others read the information writed by the
    >> first one.
    >>

    >Use shared memory, see shmget and friends.


    no, see mmap with MAP_SHARED and friends. Also flock and friends.

    --
    mac the na´f

  8. Re: Shared memory between process

    Alex Colvin wrote:
    >>>Exists any way of creating a shared memory (or any other similary
    >>>functionality) that can be accessed by more than one process? if yes
    >>>what are the required functions in c/c++. I only required that one
    >>>process writes and all the others read the information writed by the
    >>>first one.
    >>>

    >>
    >>Use shared memory, see shmget and friends.

    >
    >
    > no, see mmap with MAP_SHARED and friends. Also flock and friends.
    >

    Why the no?

    --
    Ian Collins.

  9. Re: Shared memory between process

    Ian Collins wrote:
    > Alex Colvin wrote:
    >
    >>>>Exists any way of creating a shared memory (or any other similary
    >>>>functionality) that can be accessed by more than one process? if yes
    >>>>what are the required functions in c/c++. I only required that one
    >>>>process writes and all the others read the information writed by the
    >>>>first one.
    >>>>
    >>>
    >>>Use shared memory, see shmget and friends.

    >>
    >>
    >>no, see mmap with MAP_SHARED and friends. Also flock and friends.
    >>

    >
    > Why the no?
    >


    because shmget sucks ? maybe ?


  10. Re: Shared memory between process

    Gianni Mariani wrote:
    > Ian Collins wrote:
    >
    >> Alex Colvin wrote:
    >>
    >>>>> Exists any way of creating a shared memory (or any other similary
    >>>>> functionality) that can be accessed by more than one process? if yes
    >>>>> what are the required functions in c/c++. I only required that one
    >>>>> process writes and all the others read the information writed by the
    >>>>> first one.
    >>>>
    >>>> Use shared memory, see shmget and friends.
    >>>
    >>> no, see mmap with MAP_SHARED and friends. Also flock and friends.
    >>>

    >> Why the no?

    >
    > because shmget sucks ? maybe ?
    >

    I the interface is on the clunky side and the potential for stale pages
    is real, but I always used to to use it. These days I prefer doors, but
    I guess they aren't portable.

    --
    Ian Collins.

  11. Re: Shared memory between process

    Ian Collins wrote:
    ....
    > I the interface is on the clunky side and the potential for stale pages
    > is real, but I always used to to use it. These days I prefer doors, but
    > I guess they aren't portable.
    >


    woz doors ?

  12. Re: Shared memory between process

    Gianni Mariani wrote:
    > Ian Collins wrote:
    > ....
    >
    >> I the interface is on the clunky side and the potential for stale pages
    >> is real, but I always used to to use it. These days I prefer doors, but
    >> I guess they aren't portable.
    >>

    >
    > woz doors ?


    http://blogs.sun.com/tucker/entry/door_api_details

    --
    Ian Collins.

  13. Re: Shared memory between process

    >>>Use shared memory, see shmget and friends.

    >> no, see mmap with MAP_SHARED and friends. Also flock and friends.


    because mmap and flock use the file system to name shared objects and
    control access.
    shmget and friends live in their own world, with their own names.

    shmget is from the days before virtual memory and mmap.
    you can do more with mmap.
    --
    mac the na´f

+ Reply to Thread