2

Need to understand virtual memory concept.

When a process requesting for 2GB mapping onto the virutal memory in Linux environment of 4GB ( 1GB Kernel : 3GB Userspace), when already another process already holds the mapping for 2 GB.

How does the mapping of the stack, heap, data segments all going to happen? I am not able to find any example for my understanding. Text book only mentions separately for each mapping but not a practical approach.

2
  • I don't think I understand your question. In a 32-bit environment (address space 4GiB total), if a process already holds a mapping of size 2GB and it requests another mapping of size 2GB, then the second mapping will simply fail. There isn't enough space. That's all there is to it.
    – Celada
    Jun 16, 2015 at 7:10
  • sorry for the confusion, its not the same process requesting another mapping. Its one process requesting mapping while another already holds the mapping
    – Madara
    Jun 16, 2015 at 8:27

1 Answer 1

1

Let's assume that we have 3 GiB of virtual address space available and that a process' text, stack, heap, and prior memory mappings together occupy only a small amount of address space (much less than 1 GiB). Then if this process requests a mapping of size 2GB then there is no problem, there is plenty of space to accommodate that mapping.

(Actually, there would be one small case where this is not true: if the process' existing mappings were fragmented and scattered around the address space and there was no contiguous 2GB range of addresses available. But that's unlikely).

What mappings are or are not present in a different process' address space has nothing to do with it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .