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
Re: Shared memory between process
Nuno wrote:[color=blue]
> 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.
>[/color]
Use shared memory, see shmget and friends.
--
Ian Collins.
Re: Shared memory between process
On Apr 11, 2:01 am, "Nuno" <nuno.escul...@gmail.com> wrote:
[color=blue]
> 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.[/color]
man shm_open
Re: Shared memory between process
In article <1176253289.256687.213950@y5g2000hsa.googlegroups.com>,
"Nuno" <nuno.esculcas@gmail.com> wrote:
[color=blue]
> Hello,
>
> Exists any way of creating a shared memory (or any other similary
> functionality) that can be accessed by more than one process?[/color]
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, [email]barmar@alum.mit.edu[/email]
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 ***
Re: Shared memory between process
Nuno wrote:[color=blue]
> 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.[/color]
man mmap
I find this is better than shmget.
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:
[url]http://www.codemaestro.com/reviews/review00000107.html[/url]
Nuno
Gianni Mariani escreveu:[color=blue]
> Nuno wrote:[color=green]
> > 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.[/color]
>
> man mmap
>
> I find this is better than shmget.[/color]
Re: Shared memory between process
>> Exists any way of creating a shared memory (or any other similary[color=blue][color=green]
>> 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.
>>[/color]
>Use shared memory, see shmget and friends.[/color]
no, see mmap with MAP_SHARED and friends. Also flock and friends.
--
mac the naïf
Re: Shared memory between process
Alex Colvin wrote:[color=blue][color=green][color=darkred]
>>>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.
>>>[/color]
>>
>>Use shared memory, see shmget and friends.[/color]
>
>
> no, see mmap with MAP_SHARED and friends. Also flock and friends.
>[/color]
Why the no?
--
Ian Collins.
Re: Shared memory between process
Ian Collins wrote:[color=blue]
> Alex Colvin wrote:
>[color=green][color=darkred]
>>>>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.[/color]
>>
>>
>>no, see mmap with MAP_SHARED and friends. Also flock and friends.
>>[/color]
>
> Why the no?
>[/color]
because shmget sucks ? maybe ?
Re: Shared memory between process
Gianni Mariani wrote:[color=blue]
> Ian Collins wrote:
>[color=green]
>> Alex Colvin wrote:
>>[color=darkred]
>>>>> 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.
>>>[/color]
>> Why the no?[/color]
>
> because shmget sucks ? maybe ?
>[/color]
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.
Re: Shared memory between process
Ian Collins wrote:
....[color=blue]
> 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.
>[/color]
woz doors ?
Re: Shared memory between process
Gianni Mariani wrote:[color=blue]
> Ian Collins wrote:
> ....
>[color=green]
>> 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.
>>[/color]
>
> woz doors ?[/color]
[url]http://blogs.sun.com/tucker/entry/door_api_details[/url]
--
Ian Collins.
Re: Shared memory between process
>>>Use shared memory, see shmget and friends.
[color=blue][color=green]
>> no, see mmap with MAP_SHARED and friends. Also flock and friends.[/color][/color]
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