home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17206 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  1.8 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
  2. From: torvalds@klaava.Helsinki.FI (Linus Torvalds)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: VM wizards - verify this please
  5. Message-ID: <1992Nov19.183029.9447@klaava.Helsinki.FI>
  6. Date: 19 Nov 92 18:30:29 GMT
  7. References: <5623@krafla.rhi.hi.is> <1992Nov19.181645.7977@klaava.Helsinki.FI>
  8. Organization: University of Helsinki
  9. Lines: 39
  10.  
  11. Arghh.  I really should read the questions a bit more carefully..  My
  12. answer to nr 3 wasn't actually an answer to the question. 
  13.  
  14. In article <1992Nov19.181645.7977@klaava.Helsinki.FI> torvalds@klaava.Helsinki.FI (Linus Torvalds) writes:
  15. >In article <5623@krafla.rhi.hi.is> sigurasg@rhi.hi.is (Sigurdur Asgeirsson) writes:
  16. >>
  17. >>3. When swapping out:
  18. >>   All pagetables are searched for in-core pages and those are swapped
  19. >>   out by saving them to disk, decrementing the share count and freeing
  20. >>   if share count == 0.
  21. >>   This result in multiple copies of shared pages in swap, and, on next
  22. >>   reference, in memory, does it not? (and why all the ','?)
  23.  
  24. Actually, it doesn't result in multiple copies of the same page being
  25. swapped out: shared pages are *not* swapped out at all. 
  26.  
  27. The algorithm for swapping out a page is:
  28.  
  29.   (a) is the page clean?
  30.  
  31.     yes - just forget it and decrement the page counter.  We know we
  32.     can always re-demand-load it (or share it, or just fill it with
  33.     zero's or whatever)
  34.  
  35.   (b) is the page dirty?
  36.  
  37.     if it's used by more than 1 process we don't swap it out at all:
  38.     it's too complicated to try to find all the copies of the page
  39.     etc.. 
  40.  
  41.     if mem_map[] for the page is 1, we swap it out and free the
  42.     page. 
  43.  
  44. So the result of the above is that shared pages are never written out to
  45. swapspace, although they can be forgotten about (safely) if they are
  46. clean.  Most shared pages are clean anyway (shared pages can be dirty
  47. only after a fork()). 
  48.  
  49.         Linus
  50.