0

Using shmget(), we can allocate a shared memory block of certain size in bytes and using shmat(), we attach this shared memory block to the address space of the calling process.

I need to check my understanding:
We have one process creating and attaching a shared memory using shmget() and shmat(), and another process that is attaching this shared memory to its address space using shmat().

Now the return address of this shared memory (using the shmat()) is different in the two processes because this is an virtual address.

However, the shared memory block itself has a single base physical address that is mapped to different virtual addresses of the processes sharing this memory. Is this correct?

1 Answer 1

3

Yes, that is correct. It's the idea of shared memory that different processes can map the same actual memory; and because of virtual addressing, these addresses don't have to be the same.

You can even map the same shared memory pages into the same process twice at different addresses – that's, for example, how GNU Radio (classically) double-maps a buffer to emulate a ring buffer, where writing at the end means writing at the beginning.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.