Hello everyone,
I can understand hard page fault is we need to load from page file into working set (RAM). But what is a soft page fault? I am confused.
thanks in advance,
George
Hello everyone,
I can understand hard page fault is we need to load from page file into working set (RAM). But what is a soft page fault? I am confused.
thanks in advance,
George
How about using Google ? The first link for "soft page fault" will answer the question.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Thanks nvoigt,
I found,
http://blogs.msdn.com/greggm/archive.../21/61237.aspx
But do not quite understand what the 2 situations below mean when there is soft page fault. Could you give more information please?
1. wants to be zero (called ‘demand zero’ pages)
2. when a page is written to for the first time (‘copy on write’ pages)
If you have any good comments, it is appreciated if you could share and if you have other good resources links for this topic, could you share please?
regards,
George
Did you google "demand zero" and "copy on write" ? They do exactly as their name says:
demand zero -> demands a page that is filled with zeroes. Therefore, it has to be a new page, but the new page doesn't need to be read from disk, it can be filled without disk access.
copy on write -> Means that the page is already in use. The processes will share the page until one writes to it. Only then will a copy be made. As the page is already active, it has not to be loaded from disk.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
There are several cases for "soft page faults":
1. Administrative "not present" for statistics - if the OS wants to know if a page is being accessed, the OS can set the page not present, and then see if it gets a page-fault within a given time. If there's no page-fault, then it's probably a good candidate for "removing from memory".
2. Demand paging. This, as has been explained, falls into two categories:
- Copy on write. For example data sections in DLL's can be shared between multiple processes until such a time that the data has been modified. If there is large amounts of rarely modified data, the saving can be quite large. The original data is marked read-only, and when a write happens, a page-fault handler allocates a new page and copies the original data - this page is then set writable.
Copy on write also happens in Linux when a process is Forked, where the new process gets the same pages as the old process, but the new process pages are marked read-only. Again, the page-fault handler copies the data into a newly allocated page, which is writable.
3. Zero-pages, where a large block of memory is supposed to be zero, but until an access actually happens, there is no backing memory [e.g. a process allocates 2MB for a document, then loads it with 38KB of data - so the remaining 1.9+MB is never touched - no reason to actually take up REAL memory for alll those pages of zeros, right?] When the document then expands beyond 40KB [next 4KB limit], the OS will need to fill in another zero-filled page. It just allocates a new page and fills it with zero.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Thanks Mats and nvoigt,
First of all, my apologies to always forget to merge posting in the past. :-)
Two more comments,
1. About copy on write as you mentioned below, for the new page -- which needs to grant write privilege, yes, there is no need to do I/O, and only need to copy the read-only page to a new writatble page. It is fine to the new page. But, it will cause (if memory is low) other pages to swap out to swap page file. And if such swap-out pages will be demanded later, there will be hard page fault for the pages. Actually, increasing the size of physical RAM (working set) will usually cause the issue I mentioned above. Any comments?
2. About demand for zero as you mentioned below, for the new page whose value is all 0 in initial state -- it is more accurate to say that the page is not allocated in physical RAM (working set) until the current process demands it. So, it is a page allocation operation (and initialize it with all 0 after initialization). Right?
And the same, it will cause (if memory is low) other pages to swap out to swap page file. And if such swap-out pages will be demanded later, there will be hard page fault for the pages. Actually, increasing the size of physical RAM (working set) will usually cause the issue I mentioned above. Any comments?
regards,
George
Last edited by George2; 01-10-2008 at 05:47 AM.
Of course, if you allocate a new page, if there isn't sufficient free pages, there will have to be a "swap-out" of a page.
This is the same as if an application requests more memory for any other reason, including the swap-in of another page for an application.
I'm not sure what your point is....
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Let me summarize what I think you are saying:
All soft-page-faults except number 1 [statistical/administrative] are allocating pages.
Yes, I agree with that.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.