3

From what I understand, demand paging is basically paging with swapping, so you can swap in a page when it is needed. But page replacement seems like more or less the same thing, where you bring in a page is needed and switching it with an existing page in physical memory.

So is there a distinct difference?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Steven Hsu
  • 183
  • 1
  • 3
  • 15
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Apr 26 '15 at 05:16
  • Homework dump, same as: http://stackoverflow.com/questions/29876785/explain-frame-allocation-vs-page-replacement-algorithm-in-memory-management – Martin James Apr 27 '15 at 12:47
  • I'm voting to close this question as off-topic because it's a homework dump, as revealed by later 'question': http://stackoverflow.com/questions/29876785/explain-frame-allocation-vs-page-replacement-algorithm-in-memory-management – Martin James Apr 27 '15 at 12:48

2 Answers2

4

In a system that uses demand paging, the operating system copies a disk page into physical memory only if an attempt is made to access it and that page is not already in memory (i.e., if a page fault occurs). It follows that a process begins execution with none of its pages in physical memory, and many page faults will occur until most of a process's working set of pages is located in physical memory. This is an example of a lazy loading technique.

From Wikipedia's Demand paging:

Demand paging follows that pages should only be brought into memory if the executing process demands them. This is often referred to as lazy evaluation as only those pages demanded by the process are swapped from secondary storage to main memory. Contrast this to pure swapping, where all memory for a process is swapped from secondary storage to main memory during the process startup.

Whereas, page replacement is simply the technique which is done when there occurs a page-fault. Page replacement is a technique which is utilised for both pure swapping and demand-paging.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • Think in this way :- page-replacement is used in both (Demand-Paging + Pure-swapping), whereas demand-paging is a specific-type. – Am_I_Helpful Apr 26 '15 at 04:30
0

Page Replacement simply means swapping two processes between memory and disk.

Demand Paging is a concept in which only required pages are brought into the memory. In case where a page required is not in the memory, the system looks for free frames in the memory. If there are no free frames, then a page replacement is done to bring the required page from the disk to the memory.

Aditya
  • 677
  • 2
  • 9
  • 15