0

When all pages are used up, will the operating system remove a page to make space for the new page, or will it be OOM?

What if we delete the binary while the process is running. When there is a page fault and the operating system tries to load the page from the disk but cannot find it, what will happen?

Kevin
  • 2,775
  • 4
  • 16
  • 27

1 Answers1

1

The answer depends on the binary. No swap space is needed for the text segment as this segment is mapped read-only into memory. If all of the physical frames are full and a page containing text is evicted, the physical frame is cleared but the page is not written back to disk, because the text is already present in the binary on disk. The data segment, however, will need to be written to swap space as the process can write to the global variables in the data segment. Thus, the answer depends on how large the data segment is. Of course, the stack and the heap will also need swap space. I suppose if the data segment is not too large, you can constrain the size of the stack and heap and not use swap space.

When you delete a binary while a process using the binary is running, the binary file is just unlinked from the directory structure. The binary is not removed from the file system until the last process using the binary is terminated.

Jack Humphries
  • 13,056
  • 14
  • 84
  • 125