小编ska*_*iya的帖子

linux共享内存实际位于何处?

我只想知道共享内存在Linux系统中的位置?它是在物理内存还是虚拟内存中?

我知道进程的虚拟内存发送框,它们不同于进程到进程和进程看不到彼此的内存,但我们可以使用IPC在进程之间传递数据.为了实现简单的场景,我刚刚创建了一个简单的共享内存程序,并尝试打印共享内存地址和函数返回值shmat,但两个进程具有不同的地址但值相同.

这是写程序.

为write.c

#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>

int main() {

  key_t key=1235;
  int shm_id;
  void *shm;

  int *ptr = 83838;

  shm_id = shmget(key,10,IPC_CREAT | 0666);
  shm = shmat(shm_id,NULL,NULL);

  sprintf(shm,"%d",ptr);

  printf("Address is %p, Value is %p \n", (void *)shm, (void *)&ptr);
  printf("Shm value is %d \n", *(int *)shm);
  return;
}
Run Code Online (Sandbox Code Playgroud)

这是读者计划.

read.c

#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>

int main() {

  key_t key=1235;
  int shm_id;
  void *shm;

  int *p = (int *)malloc(sizeof(int));
  shm_id = …
Run Code Online (Sandbox Code Playgroud)

c linux memory shared-memory

10
推荐指数
1
解决办法
7233
查看次数

以编程方式将SVG形状转换为路径(lineto,moveto)

我有一个来自Inkscape,Illustrator或任何其他应用程序的SVG文件.我想形状转换为lineto,moveto,curveto格式.

我想要的是:

./Appname svgfile outfilewithpath
Run Code Online (Sandbox Code Playgroud)

我将SVG文件作为参数,然后我的应用程序将对象转换为相应的路径.

svg automation shapes save-as coordinates

8
推荐指数
2
解决办法
3453
查看次数

标签 统计

automation ×1

c ×1

coordinates ×1

linux ×1

memory ×1

save-as ×1

shapes ×1

shared-memory ×1

svg ×1