accessing a file via memory mapping - Unix

This is a discussion on accessing a file via memory mapping - Unix ; Hi Everyone, I now have a bit of idea on mmap(), using which a file's contents can be mapped to the memory and read/write interface can be avoided. I have the following doubt, assume i have a 32-bit processor with ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: accessing a file via memory mapping

  1. accessing a file via memory mapping

    Hi Everyone,

    I now have a bit of idea on mmap(), using which a file's contents can
    be mapped to the memory and read/write interface can be avoided. I
    have the following doubt,

    assume i have a 32-bit processor with 1 GB of RAM, this means that
    2^32 = 4 GB of addresses are possible and that is called that the
    address space. Does this, in anyway, limit that a file that can be
    mapped should always be less than or equal to 4 GB?

    As per my current understanding, there shouldn't be any such limit,
    whenever there is a fault the corresponding page should be loaded. Can
    anyone confirm if i'm correct or wrong, with some details.

    Thanks in advance!!!


  2. Re: accessing a file via memory mapping

    On 24 Apr, 07:17, sam_...@yahoo.co.in wrote:

    > I now have a bit of idea on mmap(), using which a file's contents can
    > be mapped to the memory and read/write interface can be avoided. I
    > have the following doubt,
    >
    > assume i have a 32-bit processor with 1 GB of RAM, this means that
    > 2^32 = 4 GB of addresses are possible and that is called that the
    > address space. Does this, in anyway, limit that a file that can be
    > mapped should always be less than or equal to 4 GB?


    It depends on operating system.

    Normally, on Linux the virtual 4Gb address space is split into 3Gb
    user space and 1Gb kernel space (although there is a patch to provide
    4Gb user address space). The user space is used for code and data,
    what left is yours.

    More info: http://www-128.ibm.com/developerwork...rary/l-memmod/


  3. Re: accessing a file via memory mapping

    >
    > It depends on operating system.
    >
    > Normally, on Linux the virtual 4Gb address space is split into 3Gb
    > user space and 1Gb kernel space (although there is a patch to provide
    > 4Gb user address space). The user space is used for code and data,
    > what left is yours.
    >


    mmap() is just a user-level virtual memory management, having said
    that, virtual memory came into picture to give a picture of having
    more memory than available. It allowed programs requiring 100 MB to be
    run on 64 MB RAM, isn't it. So shouldn't mmap allow file of any size
    to be mapped to the memory, irrespective of the address length?


  4. Re: accessing a file via memory mapping

    sam_cit@yahoo.co.in writes:
    >> It depends on operating system.
    >>
    >> Normally, on Linux the virtual 4Gb address space is split into 3Gb
    >> user space and 1Gb kernel space (although there is a patch to provide
    >> 4Gb user address space). The user space is used for code and data,
    >> what left is yours.
    >>

    >
    > mmap() is just a user-level virtual memory management,


    There is no such thing as 'user-level virtual memory management'.

    [...]

    > It allowed programs requiring 100 MB to be run on 64 MB RAM, isn't
    > it. So shouldn't mmap allow file of any size to be mapped to the
    > memory, irrespective of the address length?


    For obvious reasons, a process cannot access memory it cannot address,
    be it virtual, physical or whatnot.

+ Reply to Thread