my question is theoretical in computer OSes, specifically about hibernation.
As far as I know, hibernation (ACPI state S5, is that right?) involves writing into the hard disk all the data needed to restore RAM when OS os booted up again. OK this sounds good to me.
But, I remember the old times of Operating Systems class when the teacher explained the differences in memory management between OSes. Windows and Linux kernel both use virtual memory: all pages are initialized into swap, then loaded into RAM when needed so they can be relocated at any time.
I also know that memory pages are not immediately flushed to swap, but are kept in memory for a certain amount of time, or when there is the need to load a page from swap and all memory pages are dirty
My question is: Why does Windows need to store a separate
hiberfil.sys file with all RAM dumped inside since all pages should be already present in swap file (and hibernation would simply mean flushing the caches and stopping the computer) and almost all clean after a prolonged inactivity?
The same, why does Linux explictly say it's copying pages to swap partition? When I simply suspend the system, it takes a couple of seconds of continuous disk access before halt (perhaps kernel flushing caches), but when I want to hibernate it takes the same time it takes to restore.
Am I missing something about kernels?