Friday 6 May 2016

Windows Vs. Linux Virtual Memory Management.


Virtual Memory Management In Linux is Faster than Linux.


  • Linux Provides VM by default at time of booting by allocating some part of memory from Hard-drive and that portion of memory is converted in Linux supported data structure.
  • Whereas in case of Windows both virtual memory and RAM are having different Data-Structure. So, at time of Swap-out and Swap-in , It needs conversion of data-structure from VM type to OS supported Type and it created Delay.
  • Let suppose 



Comparison

1) Data structures

Windows

  • Windows uses tree data structure.
  • Each node of the tree is called Virtual Address Descriptors (VAD).
  • VAD marks each node as free, committed or reserved.
  • Committed nodes are those nodes that are currently being used.
  • Free nodes are unused nodes.
  • Reserved nodes cannot be used until reservation is lifted off.

Linux

  • It uses linked list data structure.
  • It maintains a list of vm_area_structs.
  • This list is searched whenever a page is to be found.
  • It also records the range of address, protection mode and the direction in which it grows (up or down).
  • If number of entries becomes more than 32, Linux converts linked list into a tree.
  • Linux uses data structure depending upon the situation.
2) Distribution of Process Address Space

Windows

  • Windows on 32 bit x86 systems can access up to 4GB of physical memory.
  • Windows allows each process to have its own 4GB logical address space by using paging.
  • The upper 2GB is kept for windows kernel mode.
  • The lower 2GB of the address space is reserved for user mode.

Linux

  • 3GB of memory space is reserved for user mode
  • 1GB is kept for Kernel mode.

3) Paging

Linux uses demand paging with no pre paging

  • Linux do not swap the entire process instead uses a lazy swapper.
  • It never swaps a page into the memory unless that page is needed.
  • Instead of swapping in a whole process, the pager swaps only necessary pages into memory.
  • It thus avoids reading pages that will not be used, this decreases swap time and amount of physical memory required.
  • To distinguish between the pages that are in memory and are on the disk we use valid and non valid bits.
  • If bit is valid it shows that the page is legal and is in the memory and if bit is set to invalid it indicates that it is on the disk.

Linux uses three level paging

Windows uses cluster demand paging

  • Pages are brought in the memory when they are needed.
  • Instead of bringing pages one by one, eight pages are brought in the memory simultaneously.
  • It makes use of working set model.
  • Working set is the amount of memory currently assigned to the process.
  • It contains the pages that are in the main memory.
  • Size of working set can be changed accordingly.

Windows uses Two Level Paging

4) Address structure

Linux

Linear address is broken into four parts:
  • Global Directory.
  • Middle Directory.
  • Page Table
  • Offset.

Windows

Address is divided into two parts:
  • Page number
  • Page offset

5) Page replacement

Linux uses LRU

  • Least Recently Used Page Replacement Algorithm (L.R.U.)
  • The page that is not used for a long period of time is selected as victim page and is replaced.
  • Implemented in two ways- Counters and stack.
  • In counters, each page table entry is associated with a time-of-use field. The page with smallest time value is replaced.
  • In stack, the page at the bottom is removed and put on the top of the stack. Least recently used is always at the bottom of the stack.
Here is an example of LRU page replacement algorithm.

No. of page faults=12

Windows uses FIFO

  • First in First out Page Replacement Algorithm (F.I.F.O.).
  • The oldest page is chosen for replacement.
  • It suffers from be lady's anomaly.
  • Page fault rate may increase when we increase number of frame.
  • It has low performance.
  • It has maximum number of page faults.
Here is an example of FIFO page replacement algorithm.

No. of page faults =155)

Windows divides virtual pages into four lists:-

  • Modified Page List.
  • Stand-by Page List.
  • Free Page List.
  • Zeroed Page List.
Pages that have been modified are in modified page list. After writing to disk they are stored in standby list. Pages that have not been modified go to stand by list. The modified page list is called dirty list and standby list is called clean list.

Linux divides the pages into four lists:-

  • Active List.
  • Inactive-dirty List.
  • Inactive clean List.
  • Free List.
Active pages are on the list 1. If some of the pages are not active, their age decreases and goes down to zero, which means it has to be removed.
Reference Link:
For more Detail on Linux Virtual memory Management:

No comments:

Post a Comment

How to install google-chrome in redhat without redhat subscription

Install google-chrome in redhat  Download the .rpm file of chrome https://www.google.com/chrome/thank-you.html?installdataindex=empty&st...