468,168 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,168 developers. It's quick & easy.

Avoid memory corruption in shared memory used by several processes?

Hi all,

I want to make data stored in-memory (not disk) available to several
processes. My concern is that poorly written C applications with
dangling pointers may(will) damage the data in this memory segment if
it is open to all, i.e. shared memory mapped into all processes memory
area.

I don't want to use TCP/IP client/server between the apps and a data
store process due to the overhead.

I don't want to start calculating checksums for all updates in a
shared memory area, since that means a lot of overhead.

Now my question:
Is it possible to expose just the interface of a data store component
and have that i/f shared between all processes who want to access the
data, and then have this shared interface make callbacks into a data
store process' private memory?

If yes, how do I achieve this? If not, why not?

Thanks for helping out
/Sune

Jul 6 '07 #1
12 4176
On Jul 5, 7:50 pm, Sune <sune_ahlg...@hotmail.comwrote:
Hi all,

I want to make data stored in-memory (not disk) available to several
processes. My concern is that poorly written C applications with
dangling pointers may(will) damage the data in this memory segment if
it is open to all, i.e. shared memory mapped into all processes memory
area.

I don't want to use TCP/IP client/server between the apps and a data
store process due to the overhead.

I don't want to start calculating checksums for all updates in a
shared memory area, since that means a lot of overhead.

Now my question:
Is it possible to expose just the interface of a data store component
and have that i/f shared between all processes who want to access the
data, and then have this shared interface make callbacks into a data
store process' private memory?

If yes, how do I achieve this? If not, why not?
Try news:comp.programming.threads

Jul 6 '07 #2
Sune wrote:
I want to make data stored in-memory (not disk) available to several
processes. My concern is that poorly written C applications with
dangling pointers may(will) damage the data in this memory segment if
it is open to all, i.e. shared memory mapped into all processes memory
area.
...
Is it possible to expose just the interface of a data store component
and have that i/f shared between all processes who want to access the
data, and then have this shared interface make callbacks into a data
store process' private memory?
Something like that is possible, although callbacks are used for
something different than what your describe. Standard C doesn't support
multiple processes, so this is off-topic in this newsgroup.

You need to check systems that support multiple processes. It may also
be possible, in some systems, to allow a single process to write an area
of memory and others to only read.
--
Thad
Jul 6 '07 #3
user923005 <dc*****@connx.comwrites:
On Jul 5, 7:50 pm, Sune <sune_ahlg...@hotmail.comwrote:
>I want to make data stored in-memory (not disk) available to several
processes.
[...]
Try news:comp.programming.threads
I suspect that's not the right place to ask. The OP asked about
processes, not threads; in many system, those are quite different
things.

It's probably better to ask in a newsgroup that deals with whatever
operating system the OP is using. At a guess, comp.unix.programmer
seems likely.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #4
Keith Thompson wrote:
user923005 <dc*****@connx.comwrites:
>Sune <sune_ahlg...@hotmail.comwrote:
>>I want to make data stored in-memory (not disk) available to
several processes.

[...]
>Try news:comp.programming.threads

I suspect that's not the right place to ask. The OP asked about
processes, not threads; in many system, those are quite different
things.
To share memory you either need threads or some other arrangement
to specifically share a memory block. Threads are probably the
easiest initial mechanism.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #5
CBFalconer <cb********@yahoo.comwrites:
Keith Thompson wrote:
>user923005 <dc*****@connx.comwrites:
>>Sune <sune_ahlg...@hotmail.comwrote:

I want to make data stored in-memory (not disk) available to
several processes.

[...]
>>Try news:comp.programming.threads

I suspect that's not the right place to ask. The OP asked about
processes, not threads; in many system, those are quite different
things.

To share memory you either need threads or some other arrangement
to specifically share a memory block. Threads are probably the
easiest initial mechanism.
<OT>
How exactly do threads help you share memory between proceses?

Unix-like systems typically have mechanisms to share memory between
processes; these mechanisms are independent of threads, which exist
within a single process.
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #6
Keith Thompson wrote:
CBFalconer <cb********@yahoo.comwrites:
.... snip ...
>
>To share memory you either need threads or some other arrangement
to specifically share a memory block. Threads are probably the
easiest initial mechanism.

<OT>
How exactly do threads help you share memory between proceses?

Unix-like systems typically have mechanisms to share memory between
processes; these mechanisms are independent of threads, which exist
within a single process.
</OT>
Because, at least in my mind, threads of a process all operate in
the same memory space, and all we have to do is control access.
Processes go to some trouble to keep the memory isolated.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #7
CBFalconer <cb********@yahoo.comwrites:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
... snip ...
>>
>>To share memory you either need threads or some other arrangement
to specifically share a memory block. Threads are probably the
easiest initial mechanism.

<OT>
How exactly do threads help you share memory between proceses?

Unix-like systems typically have mechanisms to share memory between
processes; these mechanisms are independent of threads, which exist
within a single process.
</OT>

Because, at least in my mind, threads of a process all operate in
the same memory space, and all we have to do is control access.
Processes go to some trouble to keep the memory isolated.
Yes, and the OP specifically asked about sharing memory among
*processes*. Maybe threads are a better solution to his underlying
problem, but you should at least mention that you're suggesting an
alternative rather than answering his actual question.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '07 #8
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
<OT>
How exactly do threads help you share memory between
proceses?

Unix-like systems typically have mechanisms to share memory
between processes; these mechanisms are independent of
threads, which exist within a single process.
Threads are sometimes referred to as lightweight processes.
</OT>
S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Jul 6 '07 #9
Stephen Sprunk wrote:
"Keith Thompson" <ks***@mib.orgwrote in message
><OT>
How exactly do threads help you share memory between
proceses?

Unix-like systems typically have mechanisms to share memory
between processes; these mechanisms are independent of
threads, which exist within a single process.

Threads are sometimes referred to as lightweight processes.
I believe Linux specifically creates processes and defeats the
memory isolation provisions in creating threads.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 7 '07 #10
"CBFalconer" <cb********@yahoo.comwrote in message
news:46***************@yahoo.com...
Stephen Sprunk wrote:
>Threads are sometimes referred to as lightweight processes.

I believe Linux specifically creates processes and defeats the
memory isolation provisions in creating threads.
Linux now has a single spawn() syscall, which takes various options; some of
them result in a separation of memory space (i.e. processes), and some don't
(i.e. threads). All the kernel cares about is scheduling threads; which
ones occupy the same memory space as others is a minor detail.

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Jul 7 '07 #11
Stephen Sprunk wrote, On 07/07/07 09:10:
"CBFalconer" <cb********@yahoo.comwrote in message
news:46***************@yahoo.com...
>Stephen Sprunk wrote:
>>Threads are sometimes referred to as lightweight processes.
<snip>

All of which is off topic. Both of you, if you want to discus it
further, take it to email or a group where it is topical please.
--
Flash Gordon
Jul 7 '07 #12
"Sune" <su**********@hotmail.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
Hi all,

I want to make data stored in-memory (not disk) available to several
processes. My concern is that poorly written C applications with
dangling pointers may(will) damage the data in this memory segment if
it is open to all, i.e. shared memory mapped into all processes memory
area.
[...]

http://groups.google.com/group/comp....86197f1882dc56

http://groups.google.com/group/comp....45e6fe981788e7

Read both of those and follow all links...

Aug 26 '07 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by alanrn | last post: by
14 posts views Thread by phil_gg04 | last post: by
16 posts views Thread by Justin Lazanowski | last post: by
2 posts views Thread by a_agaga | last post: by
10 posts views Thread by Oriane | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.