In a Operating System, who decides which parts of a program (or task) has to be stored in the virtual memory and which in the RAM ?


The application itself gets to decide what it wants in virtual memory (within some restrictions). By default that will be the code it run and the memory it uses. The application can also request files to be mapped into memory, or that memory gets shared with another application.

Then the kernel will decide which parts of virtual memory are loaded in RAM based on various factors like: how much ram is available; how much is needed by other processes; how recently a region of virtual memory was accessed, ...

  • $\begingroup$ So the program tells to the OS : "these parts can be put in virtual memory" , then the kernel choose from this parts ( the ones chosen by the program) which to put effectively in the virtual memory ? $\endgroup$ – Qwerto Apr 24 '18 at 10:00
  • $\begingroup$ Depending on your definition of virtual memory something is in virtual memory as soon as the kernel accepts that you want it in virtual memory. $\endgroup$ – ratchet freak Apr 24 '18 at 10:35
  • 1
    $\begingroup$ "Virtual memory," by definition, means the address space that the operating system makes available to the program. All of the program's code and data are in virtual memory even if parts of that virtual memory are resident in physical pages or, have been locked to physical pages. $\endgroup$ – Solomon Slow Apr 24 '18 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.