- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图将一些共享内存代码从 CENTOS(3.5) 迁移到 CYGWIN(2.8.1, win10)。共享内存通常是这样工作的:
通过 shmget 在进程中生成共享内存。
通过shmat映射该进程上的共享内存并记录位置,然后将一些信息填充到内存中。
通过“shmat”将共享内存映射到另一个进程,传递最后记录的进程的位置,因为我们期望两个进程将共享内存映射到相同的地址。
下面是一些代码来解释:
// one process
size_t size = 1024 * 1024;//1M
int id = shmget(IPC_PRIVATE, size, 0660);
char *madr = 0;
char *location = shmat(id, madr, 0);
// another process
char *location1 = shmat(id, location , 0);
// !!!we hope location1 and location should be the same!!!
在 Centos 上它运行良好。
在 Cygwin 上,一个进程将共享内存映射到 0xffd90000,另一个进程与之不同,但映射到 oxffdb0000。我们检查内存 0xffd90000 在该进程上是否可用。
最佳答案
对 Linux 的期望也是错误的,请参阅
https://linux.die.net/man/2/shmat
Be aware that the shared memory segment attached in this way may be attached at different addresses in different processes. Therefore, any pointers maintained within the shared memory must be made relative (typically to the starting address of the segment), rather than absolute.
关于Cygwin/Cygserver 共享内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45788744/
我试图将一些共享内存代码从 CENTOS(3.5) 迁移到 CYGWIN(2.8.1, win10)。共享内存通常是这样工作的: 通过 shmget 在进程中生成共享内存。 通过shmat映射该进程上
我是一名优秀的程序员,十分优秀!