How does Virtual Memory prevent one process from overwriting otherprocess' data? - Unix

This is a discussion on How does Virtual Memory prevent one process from overwriting otherprocess' data? - Unix ; Hi, I've been confusing by virtual memory mechnism. 1. How does Virtual Memory prevent one process from overwriting other process' data? Different processes probably have SAME virtual address. I'm wondering how page table handle this case. 2. How is page ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How does Virtual Memory prevent one process from overwriting otherprocess' data?

  1. How does Virtual Memory prevent one process from overwriting otherprocess' data?

    Hi,

    I've been confusing by virtual memory mechnism.

    1. How does Virtual Memory prevent one process from overwriting other process'
    data? Different processes probably have SAME virtual address. I'm wondering how
    page table handle this case.

    2. How is page table is setup and modified dynamically? For example, there's a
    new process created, how is its memory mapped by page table?

    thanks,
    Hunter
    =====


  2. Re: How does Virtual Memory prevent one process from overwriting other process' data?

    On Thu, 25 Sep 2008 18:26:05 +0800,
    Hunter Hou wrote:
    > I've been confusing by virtual memory mechnism.


    *cough* That sounds like homework, but anyway.

    [formatting corrected]
    > 1. How does Virtual Memory prevent one process from overwriting other
    > process' data? Different processes probably have SAME virtual address.
    > I'm wondering how page table handle this case.


    Simply put, it doesn't. The MMU sets limits on what address space a
    process may access. But once you understand how swapping in a virtual
    memory environment works, it's not hard to see how Copy-on-Write uses
    the same tricks to save having to allocate memory to contain the same
    stuff again until it is actually written to.

    As to virtual addresses, each process has its own virtual address space.
    That, frankly, is part of the point of having a virtual memory system.
    Another point is to be able to move physical pages around, and in and
    out of actual memory. Thus enabling swap on some other storage medium.


    > 2. How is page table is setup and modified dynamically? For example,
    > there's a new process created, how is its memory mapped by page table?


    You perhaps should get yourself a copy of, oh, [1] or [2] and read all
    about how operating systems' virtual memory mamangement works. Or
    google around a bit and stumble on things like [3] or [4]. Also, [5].


    [1] _Operating Systems Design and Implementation, 3/E_,
    Andrew S Tanenbaum, Albert S Woodhull
    [2] _The Design and Implementation of the FreeBSD Operating System_,
    Marshall Kirk McKusick, George V. Neville-Neil
    [3] http://www.freebsd.org/doc/en/articles/vm-design/
    [4] http://www.freebsd.org/doc/en/books/design-44bsd/
    [5] _Lions' Commentary on UNIX 6th Edition, with Source Code_,
    John Lions

    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

  3. Re: How does Virtual Memory prevent one process from overwritingother process' data?



    On 9/25/2008 7:20 PM, jpd wrote:
    > On Thu, 25 Sep 2008 18:26:05 +0800,
    > Hunter Hou wrote:
    >
    >>I've been confusing by virtual memory mechnism.

    >
    >
    > *cough* That sounds like homework, but anyway.


    Acturally I'm teaching myself about operating system.

    >
    > [formatting corrected]
    >
    >>1. How does Virtual Memory prevent one process from overwriting other
    >>process' data? Different processes probably have SAME virtual address.
    >>I'm wondering how page table handle this case.

    >
    >
    > Simply put, it doesn't. The MMU sets limits on what address space a
    > process may access. But once you understand how swapping in a virtual
    > memory environment works, it's not hard to see how Copy-on-Write uses
    > the same tricks to save having to allocate memory to contain the same
    > stuff again until it is actually written to.
    >
    > As to virtual addresses, each process has its own virtual address space.
    > That, frankly, is part of the point of having a virtual memory system.
    > Another point is to be able to move physical pages around, and in and
    > out of actual memory. Thus enabling swap on some other storage medium.
    >
    >
    >
    >>2. How is page table is setup and modified dynamically? For example,
    >>there's a new process created, how is its memory mapped by page table?

    >
    >
    > You perhaps should get yourself a copy of, oh, [1] or [2] and read all
    > about how operating systems' virtual memory mamangement works. Or
    > google around a bit and stumble on things like [3] or [4]. Also, [5].
    >


    Acturally I'm reading the [2] and raised my questions. It doesn't looks clear to
    me.
    1. page table is per-process or it's a global array maintained only by kernel?
    2. How to define how much a virtual space is?

    It would be better for [2] to provide more pictures.

    [5] is a good book and I finished it. Understand a lot. It looks to me that [5]
    has no virtual memory stuff.

    Thanks for your help.
    >
    > [1] _Operating Systems Design and Implementation, 3/E_,
    > Andrew S Tanenbaum, Albert S Woodhull
    > [2] _The Design and Implementation of the FreeBSD Operating System_,
    > Marshall Kirk McKusick, George V. Neville-Neil
    > [3] http://www.freebsd.org/doc/en/articles/vm-design/
    > [4] http://www.freebsd.org/doc/en/books/design-44bsd/
    > [5] _Lions' Commentary on UNIX 6th Edition, with Source Code_,
    > John Lions
    >



  4. Re: How does Virtual Memory prevent one process from overwriting other process' data?

    On Sun, 28 Sep 2008 12:25:39 +0800,
    Hunter Hou wrote:
    [quotes trimmed, line lengths cut down to size]
    > 1. page table is per-process or it's a global array maintained only
    > by kernel?


    Would you let a process change its page tables itself?

    The exact layout of the page table structure(s) are system dependent, so
    even the same OS will have to use different structures across different
    CPU architectures for telling the CPU about its page layout decisions.


    > 2. How to define how much a virtual space is?


    How much of what, in what sense? Page sizes are fixed, but how many pages
    the OS allocates is a function of the OS's wishes, the application's
    wishes, hardware limits, and administrative choices. Also mind that some
    systems including linux ``oversubscribe''; it allocates more pages than
    available. Should it find it has painted itself into a corner, it'll start
    killing processes to get out of dodge (the ``OOM killer'').


    > [5] is a good book and I finished it. Understand a lot. It looks to me
    > that [5] has no virtual memory stuff.


    No. I recalled that after posting (VAX had virtual memory support, PDP
    didn't), but even so I couldn't very well leave it off the list.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

+ Reply to Thread