Tuesday, September 2, 2008

SEB070011-TUTORIAL 4























Windows UNIX/Linux
Windows sets amount of virtual memory at boot time, so, it is based on the amount of free physical RAM and responsible for managing the physical pages. The pages that map to the Win32 is based on the application's code and data that are reserved at application initialization time. This will decrease the available virtual memory but not available for RAM. Unix and its related systems use very sophisticated memory management algorithms to make the use of memory resources efficiently. The total real memory is calculated by subtracting the kernel memory from the amount of RAM but the total virtual memory is depended on the degree to which the processes use mapped files. The limitation for data and stack space is the amount of real and swap memory.

Windows handles the page faults by investigating the following program-related problems:

1.Confirm bugs in Microsoft Access.

2.A damaged or fragmented database.

3.A corrupted database.

4.Incorrect registry settings.

5.Mismatched dynamic link libraries (DLLs)

Once the investigation is done and is determined that the causes of the problems are none of these above, the following system-related problems will be done for further investigations :

1.A memory conflict.

2.A Temp folder (directory) problem

3.A video driver and settings problem

4.A printer driver and settings problem

5.Incorrect virtual memory settings

6.Incorrect file-system settings


7.Hard disk fragmentation or errors

CPU is tried to access a page that is not in main memory when page faults is occurred and thus forcing the CPU to wait for the page to be swapped in. The goal of the memory manager is to minimize the number of page faults especially when we moving data to and from disks takes a significant amount of time.


The Linux page faults handler acquiring a read-write semaphore (mmap_sem) and a spin lock, the page_table_lock for synchronization between multiple threads of a task. Firstly, it acquires a read lock on mmap_sem (which alone would allow other threads to continue processing page faults) and a spin lock on the page_table_lock (which serializes access to the page table and important data structures) before acquiring a free page from the page allocator. The page is then cleared by overwriting the contents with zeros and is assigned to the process by creating a corresponding page table entry in the page table of the process. Cache line bouncing has a critical influence on page fault performance in SMP systems and particularly significant for large applications (like huge databases or computational applications) that try to minimize the startup time by having multiple threads of a process running on different processors.

Windows chooses a page size of 4K because that was the only page size supported by that architecture at the time the operating system was designed. (4MB pages were then added to the CPU later in the Pentium but clearly that is too large for everyday use.)

For ia64, Windows chose a page size of 8K. which it is a balance between two competing objectives. Large page sizes allow more efficient I/O .However large page sizes will increase the likelihood that the extra I/O perform is wasted because of   poor locality.

Experiments were run on the ia64 with various page sizes show that 8K provided the best balance.

A page is a fixed length block of main memory, which contiguous in both physical memory addressing and virtual memory addressing. Kernel swap and allocates memory using pages. The page size in Linux is fixed to 4kb/4mb/2mb. If page size is 4kb and a file has a size of 13kb then file will consume four pages, which three pages of 4kb each and last page will have only 1kb of data in it. This will result in waste of memory of 3kb in the last page (internal fragmentation).
Thrashing is caused mainly by the file indexing but not with page file. Indexing usually happens in the first 15mins after we boot up. To avoid thrashing issues in windows, the first thing to do is trying to make the page file at a fixed size of about 1024Mb on a second HD if possible. Inserting a spare USB memory stick for ready boost helps in reduce thrashing . Under allocation of the minimum number of pages required by a process, thrashing happens and forcing it to continuously page fault. The system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming and can be eliminated by reducing the level of multiprogramming.




http://www.dataexpedition.com/~sbnoble/Tips/memory.html
http://support.microsoft.com/kb/124137
http://support.microsoft.com/kb/208488/en-us
http://www.geekinterview.com/question_details/3195

No comments: