I’m a a total noob in this field, so please bear with my question and answer it 🙂
I was reading about process address space, virtual memory and paging. I understood the mechanism of pages being swapped in and out of RAM. It is documented that every process is given a virtual address space of 4GB, out of which a portion is for user space (specific to each process – 1 or 2 GB) and the rest is kernel space (which is common across all processes).Since the vritual address space for each process is stored in secondary storage, does it mean that every time I launch a process, it reserves 4 GB in my hard disk ? I don`t see my hard disk space being reduced by 4GB each time I start a process… or is it something like the virtual space is not reserved as a block but rather starts small and can grow upto 4GB. Please shed some light, and also do post some links on the topic if you know any.. anything that would help me understand this complex topic.
It is offtopic here and one could elaborate hundreds of pages text about (see the cs books on this topic).
But in short you are wrong: virtual memory is NOT stored in secondary storage. It can be there, but usually it is not. The OS is handling it, depending on its information it keeps the data in normal memory (e.g. when then process is active), or it is on hdd (e.g. when the memory is short and the process is inactive).
The virtualisation means, that for the process it is transparent, it does not know where the data is stored, it is always accessed via the same pointer. The system can change the underlying storage depending on the circumstances (it is then swapping data in or out).