Windows IPC使用共享内存 [英] Windows IPC Using Shared memory

查看:160
本文介绍了Windows IPC使用共享内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我重新解释一下这个问题: -

说过程A和B.



1.'A'创建命名共享内存( CreateFileMapping)

2.'B'打开共享内存(OpenFileMapping)

3.'A'异常终止。或者让我们说它只是正确退出。



考虑过程A可以不向进程B发出信号终止的情况。



- >内存是否仍然存在?如果是这样,需要多长时间?

- > Process B期望在这里面对什么。



------ -----------------------------

您好,

我可能会重复一个问题或者应该知道但是通过各种博客搜索还没有让我理解。



我正在创建一个IPC应用程序,其中一个进程创建一个共享内存和另一个进程访问它。

两个进程都将读/写。线程和同步正在处理中。

我的问题是当创建者异常崩溃时内存会发生什么。

1.创建者时我会发现什么?崩溃?

2.访问的应用程序是否会面临错误的指针/访问冲突?

3.它会永远可以访问还是在以后的某个时间点变坏?



我实际上想要访问的应用程序(打开文件视图)立即了解它,以便它可以完成我需要在上层做的业务逻辑。



请让我知道或指向我某些信息来源。



谢谢!!

Let me rephrase the question:-
Say process A and B.

1. 'A' creates named shared memory (CreateFileMapping)
2. 'B' opens shared memory (OpenFileMapping)
3. 'A' terminates abnormally. Or lets say it just exits properly.

Consider situations in which Process A can "NOT" signal process B that it is terminating.

-->Does the memory persist? If so, for how long?
-->What does Process B expect to face here.

-----------------------------------
Hello,
I may be repeating a question or should have known but searching through various blogs hasn't yet made me understand.

I am creating an IPC application where one process creates a shared memory and the other process accesses it.
Both processes are going to read/write into it. Threads and synchronization is being taken care.
The question I have is that what happens to the memory when the creator crashes abnormally.
1. What do I expect when the creator crashes?
2. Will the accessing application face a "bad pointer"/ access violation?
3. Will it be accessible forever or go bad at some later point of time?

I in fact want the accessing application (which opens view to file) to get to know immediately so that it can do the business logic I need to do at the upper layer.

Please let me know or point me to some source of information.

Thanks!!

推荐答案

引用:

我的问题是当创建者异常崩溃时内存会发生什么。

The question I have is that what happens to the memory when the creator crashes abnormally.



无论原因是什么,后果都可以'好的。

最好不要崩溃。

使用技术如 try / catch 来保护代码中有风险的部分。

删除尽可能多的错误,调试器将有助于捕获错误。


Whatever the reason, consequences can't be good.
The best is to not crash at all.
Use technic like try/catch to guard risky parts of your code.
Remove as much bugs as possible, the debugger will help catch bugs.


这篇关于Windows IPC使用共享内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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