Using memory outside the standard primary memory block.

Memory problems
  Speed 
    Solution: cache - expensive and limited in size.

  Amount
    Two issues
      Limited address range (Older designs)

      Limited real memory in designs with large address range.

Limited address range
  Early cpu/system design of 8088.

  1 Meg limit - both hardware and DOS 16-bit OS.

  0-1023 - table of  256 4-byte interrupt pointers 
    Configured by the ROM bios.

    Early exploitation by viruses.

    On newer OS designs, designated as  protected memory.

  1K - 640K for os, user programs, and data.
    640K  User memory. 

  640K to 1 Meg available for hardware expansion 
     (video, hd controller)

  Early PC came with only 384K of user memory.
    Cost and discourage competition with IBM's mainframe.


Expanded memory - Early attempt to overcome 640 K memory limit.
  Games and spreadsheets quickly developed the need for more memory.
    Not for program but for data.

  Standard invented by Lotus, Intel, and Microsoft (LIM)
    LIM 2.0 standard.

  Card with additional memory and support circuits added.
    Using one of the expansion areas in the 784-960k address range.

  Card can hold up to 8 Meg of additional physical memory.

  Card provides blocks (pages) of memory in a 64K contiguous address range
    visible to cpu.  CPU sees a 64K memory block.

  Parsed into 16K page slots (similar to lines of cache).
    Each individual page slot contains a linear sequence of addresses.

    However, two adjacent "pages" may be from different physical memory pages
      on the memory board.

  Pages are swapped (decoded) into and out of the various 16 K slots.

  Requires OS (Microsoft), system hardware (Intel), 
    and application to cooperate (Lotus).

    LIM 2 - only data stored in expanded memory.

    Used mostly for spreadsheet software.

    Some games also took advantage of EMM.


  LIM 4.0 - updates to LIM 2 merged with alternative expanded memory systems.
    Allowed for 64 16K pages or the full 1MB address range to be mapped to 
    the emm board.  
 
    This allowed for all of several program to be stored in expanded memory 
      pages which could be swapped in or out (multitasking).
      

  Expanded memory
     Slower than directly mapped memory
     But faster than using hard drive based virtual memory.

  On systems with enough real memory and larger address ranges, 80286 and up
    Virtual expansion card simulated by OS level software.
      EMM386 - Microsoft, came with the OS.
      QEMM, etc. - Quarterdeck comercial versions and others.

  Used to run older software.

  Expanded memory support was primarily implemented in DOS.
    But was included in early versions of Windows.

  Support dissapeared around Windows 98?

  Newer software uses extended memory - directly addressed memory > 1 Meg.


Bank Switching - generic form of expanded memory.
   Used in early pcs (Comodore 64, Apple II, etc).
     Where a memory location in valid address range is  a decoder/latch. 
       Often memory location 0 or 1. 

       Cpu supports limited address range, but latch can pick among multiple
         memory banks, each representing the full address range. 
            Must be supported by hardware and OS and/or application.

   Used in video card.
     Allows card to update one buffer (page) of memory while displaying 
       different buffer. Simple gate switch allows refreshed page to 
       immediately be displayed. Especially useful when attempting to display 
       moving images that consist of a lot of data. (32 bit color - high 
       resolution)

       (multiple buffering)

Overlays
  Precursor to DLLs.

  Technique by which a program whose total size is larger than available 
  memory claims a block of addresses and swaps blocks of functions (overlays)
  into and out of the same block of memory.
 
  Requires careful coding by programmer.  Overlays often are limited in
    size. Altough, number of overlays may be unlimited. 

  Delay during module switching but happens a small percentage of the time 
    during use of program.

    e.g. Separate modules for printing or saving.  
      Modules only swapped in when action requested.

  On PCs, normally implemented at application level.

  On embedded systems, part of the system's functionality. More predictable
    response time than virtual memory.

  Used more often with code than data.

  Modern DLLs are like high performance overlays - controlled by OS. 


Libraries
  Libaries are blocks of code performing a specific task. The same task may 
  be executed by a variety of applications, such as printing or saving a file.

  Libaries allow the code to be written once but used by many 
  users/applications.

  Static libaries and linking - at compile time a reference cause a copy of
  the block of code (routine) to be included.

  But loaded aplication becomes larger as more of these tasks are made 
  availaible, even if they aren't actually used at run time.

  And copies of the code exist in each program.  

DLL (Dynamically linked library)
  DLL - dynamically linked libraries. The task code is not part of the 
  application but loaded at run time. 

  This allows programs to be smaller in size while still having full 
  functionality.

  A single copy of the block of code is stored separately and copied when
  needed.

  Changes in the function's design immediately become available via the 
  master copy to all applications using the fuction. 
  
    Loadtime - loaded at start of program whether it is used or not. 
      Advantage - immediately available when called.

      Disadvantage - requires more memory.

    Runtime - loaded when actually called and unloaded when not being used.
      Advantage - program has smaller footprint in memory.         

      Disadvantage - time delay while dll fetched and function addresses 
      resolved.


Virtual memory
  Modern systems capable of addressing a large address space 4Gig.

  Most systems either do not have the bus support, decoder chips and
  actual traces (wires).
    or
  Memory cost prohibitive to fully populate.

Virtual memory is a way of using secondary storage (hard drive) to act
  as the additional memory needed to populate the full address range.

Virtual memory can represent the full address range of the CPU.

Virtual memory makes discontiguous blocks of memory and disk space appear 
as if they are contiguous.

Virtual memory can allow different programs to believe they are in the same
address range.

Virtual memory does require support at the system hardware level (cpu, cache,
  mmu, etc. - but not the hard drive. 
  And the OS.

  But is invisible to application.

****
  Virtual memory allows the system to use other storage to simulate primary
    memory

  Virtual memory allows a program to believe it resides in a specific 
    contiguous block of memory.