shmat() is returning a different “shmaddr” for same “shmkey”

后端 未结 3 708
-上瘾入骨i
-上瘾入骨i 2020-12-21 07:41

Here\'s my setup...

/* Bounded Buffer item structure */
struct item {
    int  id;  /* string index value */
    char str[80];  /* string value */
};

/* Str         


        
3条回答
  •  隐瞒了意图╮
    2020-12-21 07:45

    when a process calls shmat(), it will return the virtual address of the shared memory. virtual address is the memory location as seen by the current process. different process can map the shared memory to different virtual address in the process address space and hence different return values of shmat() call for different processes.

    a nice pictorial description of what I just said above. http://poshmodule.sourceforge.net/posh/html/node3.html

提交回复
热议问题