How is paging managed in the absence of swapping. If that is the case, how will a page fault be managed?

What I meant is, if there is no availability for swapping, then how is Paging managed. I know that there will be two list of pages - free_pages list and allocated_pages list. When the pages in the free_pages list becomes low, it will move the LRU pages from the allocated_pages list to the swap partition. I just want to know what will happen if there is no swap partition.


3 Answers 3


As far as I understand your question it happens usually in such way:

If you allocate memory:

  • Mark memory as allocated but don't allocate physical memory (hence on access there will be page fault). In Linux it stops at this stage but it is possible that system may allocate physical space immediately - then it performs similar algorithm at the end as on page fault except that the OOM will not happen.

If there is page fault (accessing not mapped page)

  1. Check if memory is allocated, if not return error.
  2. Check if there is free physical page. If there is goto 5
  3. Check if there is part that can be written back to disk (like file from cache) or if there is free space on swap (if there is no swap consider it as swap of size 0). If there is write file/block back to disk or write page to disk, then unmap it and goto 5. If both are possible choose any.
  4. Return OOM condition. It depends on kernel what happens - it may display error to user, kernel panic/blue screen, find some process to kill etc.
  5. Map the page that caused the problem to freed page. If page was swapped read page from swap and put it in page. If page is backed by file read file and put content there.

In general you may say that no swap is equivalent to full swap.

  • No sure about what you mean with "allocate physical space immanently (perhaps immediatly?)". In any case, Non over-committing Unixes like Solaris do reserve virtual memory at allocation time to make sure any further use would not trigger an out of memory situation. When the virtual memory is limited to physical memory, that is a real waste of RAM. That's the reason why it is always recommended to have enough swap area set with Solaris and similar Unixes.
    – jlliagre
    Jan 3, 2011 at 15:43
  • @jilliagre: Yes - wrong option chosen in spell checker. I also clarify what I meant. Jan 3, 2011 at 15:50

Swapping, allows one to move unused pages out from memory and onto a disk. However, it is not essential, to the actual paging operation, which will happen even if there is no swap.

  • That terminology vary. Swapping can be used to describe moving all memory associated to a process to/from the swap area in a single operation while (demand) paging is used when smaller fixed size blocks of memory are moved to/from the same swap area. While implemented by most Unix/Unix like OSes, swapping as described here isn't implemented in the Linux kernel so swapping and paging are often used interchangeably in this context.
    – jlliagre
    Jan 3, 2011 at 22:22
  • I am looking at it from the perspective of the processor architecture.
    – sybreon
    Jan 4, 2011 at 1:21
  • The processor architecture has little to do with these concepts. What you describe as "swapping" is what everyone else calls paging. I'm wondering what is your own definition of paging.
    – jlliagre
    Jan 4, 2011 at 11:00
  • On certain processor architectures, the page table can be paged in hardware between the MMU and primary memory. On others, this operation is handled by the OS. However, no processors are able to swap the pages to disk in hardware and rely on the OS to do this. Hence, the different terms I used to describe the concept of 'virtual memory' from a hardware perspective, as opposed to 'disk swap' in the OP.
    – sybreon
    Jan 4, 2011 at 11:52
  • Your statement "the page table can be paged in hardware between the MMU and primary memory." doesn't make sense to me. It's not the page table which is paged but blocks of memory. These blocks of memory are paged from/to primary memory to secondary storage which is usually a disk drive. The MMU isn't a storage device. Perhaps are you confusing paging memory and cache memory.
    – jlliagre
    Jan 4, 2011 at 21:01

If I understand correctly your question, you are asking how pagination occurs if no swap space is defined.

With OSes systems using the traditional Unix approach, virtual memory is always backed by physical RAM so no page faults can occur because of this missing swap area, outside of course unrelated cases like memory mapped files or bogus pointers.

With overcommitting OS like Linux, there is no strict reservation happening so the first access to an unmapped page while no more RAM is available would trigger the OOM killer or some other destructive/error event.

  • 1
    That is not actually true in for example Linux. Linux allocate physical space on access - not on allocation request. Therefore it is entirely possible for process to allocate more space then there is memory+swap still not triggering OOM as long as it do not access the memory. Additionally the mmap-ed files are written to disk rather then swap and may trigger page fault. Jan 3, 2011 at 14:05
  • Huh, I implicitly wrote my description didn't apply to Linux which is an overcommiting OS. mmap-ed files are IMHO off topic as the question is about swap.
    – jlliagre
    Jan 3, 2011 at 14:15
  • RAM used by mmaped files can be freed to their back-end so it's not that much off topic with Linux and the likes.
    – jlliagre
    Jan 3, 2011 at 14:25
  • Ups. Sorry I haven't noticed that (hence edit). Jan 3, 2011 at 14:51
  • Page faults can occur for other reasons, e.g. when a process tries to dereference an invalid pointer (pointing outside its address space). Jan 3, 2011 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .