Tuesday, September 2, 2008








New Page 1






                                              
Date:  26 August 2008


 The key to using
memory efficiently is virtual memory management. Consider both Windows and a
UNIX/Linux operating system. Compare and contrast how each implements virtual
memory. Describe how each one handles page faults, page sizes and how it
reconciles thrashing issues. Cite your sources.


 



Answer:


 Virtual
memory makes the system appear to have more memory than it actually has by
sharing it between competing processes as they need it. Systems
that use this technique make programming of applications easier and use physical
memory (e.g.

RAM
) more
efficiently than those without virtual memory.


 Compare
and contrast how each implements virtual memory 












Windows


UNIX/Linux


Windows NT and its variants
employ a dynamically allocated page file for memory management. A page file
is allocated on disk, for less frequently accessed objects in memory,
leaving more RAM available to actively used objects. This scheme suffers
from slow-downs due to disk fragmentation, which hampers the speed at which
the objects can be brought back into memory when they are needed. Windows
can be configured to place the page file on a separate partition; doing this
negates the disk-fragmentation issues, but introduces an I/O slowdown due to
the seek time involved in switching back and forth between the two
partitions. However, the main reason this is not done by default is that, if
the page file is on a separate partition, then Windows cannot create a
memory dump in the event of a Stop Error. The ideal solution
performance-wise is to have the page file on a separate hard drive to the
primary one, which eliminates both defragmentation and I/O issues.
In memory management, for example, Windows NT 5.0 and its successors use
clustered paging, a working set memory analogue and a free memory manager
that fires up exactly once per second,



         Paging



       
Available



       
Reserved



       
Committed


 


Most hard drive
installations of Linux utilize a "swap partition", where the disk space
allocated for paging is separate from general data, and is used strictly for
paging operations. This reduces slowdown due to disk fragmentation from
general use. As with Windows, for best performance the swap partition should
be placed on a separate hard drive to the primary one.


Unix uses an
adaptive page specific algorithm to control paging. In Unix, there is no
working set equivalent, and the free memory manager runs when needed


 


Paging are
performed when a program tries to access pages that do not currently reside in
RAM


 


Thrashing is swapping out a
piece of a process just before that piece is needed.
The processor spends most of its time swapping pieces rather than
executing user instructions


 




















Windows


UNIX/Linux



 Page faults


Windows
uses

structured exception
handling
to report page fault-based invalid accesses as

access violation

exceptions. Recent Windows versions also write a

minidump

(similar in principle to a

core dump
)
describing the state of the crashed process for later analysis alongside
such less-technical error messages



 


 


 Typically
use

signals
,
to report these error conditions to programs. .

UNIX

operating systems typically report these conditions to the user with error
messages such as "segmentation violation", or "bus error".


Page sizes




Win32
-based
operating system, such as Windows 9x, NT use the system function


GetSystemInfo()
from

kernel32.dll.

Windows NT provides a page-based virtual memory management scheme that
allows applications to realize a 32-bit linear address space for 4 gigabytes
(GB) of memory. As a result, each application has its own private address
space from which it can use the lower 2 GB—the system reserves the upper 2
GB of every process's address space for its own use.


 



UNIX

systems use the system function sysconf(), as illustrated in the

C

programming language.
The Unix kernel divides
the memory into manageable chunks called pages. A single page of memory is
usually 4096 or 8192 bytes (4 or 8KB). Memory pages are laid down
contiguously across the physical and virtual memory.



 


Thrashing



 
The
total number of pages is being used by this particular instruction is eight,
and all eight pages must be present in memory at the same time. If the
operating system will allocate less than eight pages of actual memory in
this example, when it attempts to swap out some part of the instruction or
data to bring in the remainder, the instruction will
again

page fault
,
and it will thrash on every attempt to restart the failing instruction.


To resolve
thrashing due to excessive paging, a user can do any of the following.


1.
Increase the amount of RAM in the computer


2.
Decrease the number of programs being run on the
computer.



 


 


 






Resourse:
• http://en.wikipedia.org/wiki/Page_size
• http://members.shaw.ca/bsanders/WindowsGeneralWeb/RAMVirtualMemoryPageFileEtc.htm 1.1.
• http://www.cs.uml.edu/~cgould/#Memory%20Management
• http://www.michaelhorowitz.com/Linux.vs.Windows.html

No comments: