Thread: Direct memory access?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    That would be a rather poor operating system, if I may say so.
    Any OS running off ROM would not have any virtual memory (since there is nothing to page the physical memory to). It has absolutely nothing to do with being a "poor operating system".

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    First, I think people are gettign virtual memory confused with paging. Virtual memory is specifically when the OS uses mass storage to create the appearance of more memory than the system has physical RAM. Hence 'virtual' memory. It does this by marking unused pages as not-present in the global descriptor table or one of the local tables. The decriptor table entry is what maps the apparent memory location to a physical memory location, or to an external device. When the processor accesses a memory location the paging unit looks up the location in the descriptor tables, and if it is marked as present uses the value in the tables to access physical memory, if it is marked as not-present, then it causes a page fault, which the OS must handle. Usually this is done by paging a not recently used page to the pagefile, and paging the needed address block into physical ram, although there are other schemes.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by abachler View Post
    First, I think people are gettign virtual memory confused with paging. Virtual memory is specifically when the OS uses mass storage to create the appearance of more memory than the system has physical RAM. Hence 'virtual' memory. It does this by marking unused pages as not-present in the global descriptor table or one of the local tables. The decriptor table entry is what maps the apparent memory location to a physical memory location, or to an external device. When the processor accesses a memory location the paging unit looks up the location in the descriptor tables, and if it is marked as present uses the value in the tables to access physical memory, if it is marked as not-present, then it causes a page fault, which the OS must handle. Usually this is done by paging a not recently used page to the pagefile, and paging the needed address block into physical ram, although there are other schemes.
    Descriptor tables (in x86) are what describes memory segments, and although those HAVE a "present" bit that needs to be set for the segment to be accessible, it's not involved in "swapping to disk" [hasn't been that way since OS/2 1.x]. Most 32-bit OS's use only two segments, shared between EVERY process in the system [1]

    Paging and virtual memory are essentially, in a modern system, done by the page-table, where pages of 4KB at a time can be made present or not present. [2]

    But paging is also used in conjunction with protection, such that each process has it's own page-table, so that only that process can access the pages that particular process owns.

    Once paging is enabled, addresses within the processor [at least on x86] are considered "virtual", meaning that the page is accessed through the page-table. The virtual to physical translation can be linear or non-linear, where a linear translation is "direct", 1:1 between the virtual and the physical address. The non-linear, any virtual address can point to "any" physical location.


    [1] Technicaly, there is a duplicate set of segment descriptors for when the OS is in the kernel, and perhaps also some other "administrative", for example a TSS segment to handle Double-Fault/Stack-Fault [in kernel mode] conditions.


    [2] Some processors and OS's support "Large pages", where pages are for example 2MB instead of 4KB, which reduces the size of the page-table for example when having large shared sections of OS memory that is common between all processes, and thus don't need the small 4KB granularity.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tools for finding memory leaks
    By stanlvw in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2009, 11:41 AM
  2. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. quick question on direct file access
    By Stevek in forum C++ Programming
    Replies: 2
    Last Post: 03-21-2003, 01:33 AM
  5. Memory Access Error when using Strcpy()
    By fgs3124 in forum C Programming
    Replies: 2
    Last Post: 03-15-2002, 03:07 PM