避免多个进程使用的共享内存中的内存损坏? [英] Avoid memory corruption in shared memory used by several processes?

查看:279
本文介绍了避免多个进程使用的共享内存中的内存损坏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想让内存(不是磁盘)中存储的数据可供几个

进程使用。我担心的是,如果

它对所有人开放,即映射到的共享内存,那么用b / b
悬挂指针编写得不好的C应用程序可能会损坏这个内存段中的数据。所有进程内存

区域。


我不想在应用程序和数据之间使用TCP / IP客户端/服务器

存储过程由于开销。


我不想开始计算

共享内存区域中所有更新的校验和,因为这意味着很多开销。


现在我的问题:

是否可以只公开数据存储组件的接口

并在所有想要访问

数据的进程之间共享i / f,然后让这个共享接口将回调转换为数据

存储进程''私人记忆?

如果是,我该如何实现?如果不是,为什么不呢?


感谢您的帮助

/ Sune

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

推荐答案

7月5日晚上7:50,Sune< sune_ahlg ... @ hotmail.comwrote:
On Jul 5, 7:50 pm, Sune <sune_ahlg...@hotmail.comwrote:

大家好,


我想将数据存储在内存(不是磁盘)中,可用于几个

进程。我担心的是,如果

它对所有人开放,即映射到的共享内存,那么用b / b
悬挂指针编写得不好的C应用程序可能会损坏这个内存段中的数据。所有进程内存

区域。


我不想在应用程序和数据之间使用TCP / IP客户端/服务器

存储过程由于开销。


我不想开始计算

共享内存区域中所有更新的校验和,因为这意味着很多开销。


现在我的问题:

是否可以只公开数据存储组件的接口

并在所有想要访问

数据的进程之间共享i / f,然后让这个共享接口将回调转换为数据

存储进程''私人记忆?

如果是,我该如何实现?如果没有,为什么不呢?
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?



尝试新闻:comp.programming.threads

Try news:comp.programming.threads


Sune写道:
Sune wrote:

我想让存储在内存中的数据(不是磁盘)可用于几个

进程。我担心的是,如果

它对所有人开放,即映射到的共享内存,那么用b / b
悬挂指针编写得不好的C应用程序可能会损坏这个内存段中的数据。所有进程内存

区域。

...

是否可以只公开数据存储组件的接口

并在所有想要访问

数据的进程之间共享i / f,然后让这个共享接口将回调转换成数据

存储进程' '私人记忆?
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?



这样的事情是可能的,虽然回调用于

与你描述的不同。标准C不支持

多个进程,因此这个新闻组中的偏离主题。


您需要检查支持多个进程的系统。在某些系统中,它也可以允许单个进程写入一个区域内存和其他只能读取的内容。

-

Thad

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


user923005< dc ***** @ connx.comwrites:
user923005 <dc*****@connx.comwrites:

7月5日晚上7:50,Sune< sune_ahlg ... @ hotmail.comwrote:
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.



[...]

[...]


尝试新闻:comp.programming.threads
Try news:comp.programming.threads



我怀疑'这不是正确的地方。 OP询问了

进程,而不是线程;在许多系统中,这些都是完全不同的。

的东西。


在新闻组中询问什么可能更好
$ OP正在使用的b $ b操作系统。猜测,comp.unix.programmer

似乎很可能。


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>

San迭戈超级计算机中心< *< http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长

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"


这篇关于避免多个进程使用的共享内存中的内存损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆