I would like to understand properly the swapping in process and yet, couldn't find a thorough explanation how pte's flags of a page are restored once a page is swapped in back to memory- since it's information is " lost" when swapping out and the corresponding disk area's adress is inserted in the pte entry of a swapped out page. I do understand that the flags of a virtual adress are stored in
vm_area_struct but couldn't trace the stage when it is used during the swap-in procedure.
another potential problem is - what happens if a parent process
forked, and both parent and child's are swapped out: as far as I consider, in both page tables-the
read_only flag is on but the
vm_area_struct allows writing since both have
VM_MAYWRITE permission for some mem-areas but once swapped out the
read_only flag in the corresponding pte is "erased" .does the COW technique is still applicable once a page they both points to once the page is swapped in and the child process wants to write?