6

The way I understand the notion of a 'process' is that it is a running instance of an executable program.The exe is in the secondary memory and the running instance of it is in the RAM. If this understanding is right, I would like to know what is really meant by this abstract description: 'Dividing a process into 'pages' and running some of the pages in RAM and keeping the rest in secondary memory for swapping when needed'? The question here is in the context of virtual memory.

Adding a 'programming' context to the question, following suggestions from moderators:

Say I write a small program to list the numbers from 1 to 100 (or) to print 'Hello world' (or) some desktop utility to scan a text file and print the words in the file one by one within the desktop window. Considering the final executable I have, once these programs are compiled and linked, how can the executable be 'divided' and run in parts in RAM when I run the executable? How shall I grasp and visualise the idea of what 'should be' in RAM at a point in time and what 'should not'?

user1907672
  • 99
  • 1
  • 4
  • 2
    It's a pretty interesting question. Wonder why it was closed by SO. Could this question be reopened? It seems relevant from the standpoint of understanding fundamentals of programming. – Chandan Feb 19 '13 at 04:04
  • Thanks Chandan. I would be glad if it is re-opened – user1907672 Feb 23 '13 at 11:45

1 Answers1

0

You have it (the division) right there, in the virtual to physical address translation. The virtual address space is split into blocks of one or several kilobytes (typically, all of the same size), each of which can be associated with a chunk (page) of physical memory of the same size.

Those parts of the executable (or process) that haven't been used yet or haven't been used recently need not to be copied into the physical memory from the disk and so the respective portions of the virtual address space may not be associated with physical memory either. When the system becomes low on free physical memory, it may repurpose some pages, saving their contents to the disk if necessary (or not saving, if they contain read-only data/code).

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
  • Thanks Alexey. I have added some more info to my question now for your reply. – user1907672 Feb 18 '13 at 07:00
  • Learn about [page tables](http://en.wikipedia.org/wiki/Page_table). – Alexey Frunze Feb 18 '13 at 07:04
  • 1
    Alexey - I did already before posting the question. In the examples presented by me, I want you to imagine the actual machine instructions inside the exe file and then tell me how those instructions would be segregated for keeping some in RAM and some in secondary memory. Which is why I would like a concrete answer and not one in the abstract sense – user1907672 Feb 18 '13 at 10:58