xmllmx
xmllmx

Reputation: 42379

What's the relations between physical pages and pages in the paging file?

Under Windows, the kernel can swap a physical memory page to a page in the paging file.

For simplicity, we assume there is only one paging file.

As far as I understand, the paging file consists of pages which have the same size of a physical memory page. i.e. 4K.

I just wonder:

How does the kernel know which page in the paging file is free to store?

(Free here means the page in the paging file doesn't previously store another physical memory page.)

Upvotes: 1

Views: 129

Answers (2)

aralar
aralar

Reputation: 3120

I believe you are asking about page replacement algorithms within memory management.

When the operating system needs to save a new page in memory and keep track of its information on the paging file (also known as the page table), there's no guarantee that there will be a free spot --meaning that other pages' information might have taken up all of it. In that case, the OS will have to evict an existing page. The OS doesn't need free space since, if there isn't any, it will make it.

If you're interested in learning more (this is a pretty large topic), you may find the lecture notes from NYU's "Operating Systems" class helpful. This is the demand paging unit, and further below you can read about a few page replacement algorithms ("WS Clock" and "Aging" are probably the most important).

Hopefully this is helpful!

Upvotes: 1

user3344003
user3344003

Reputation: 21702

At the risk of gross oversimplification . . . the usual approach in implementing virtual memory is that disk is the primary storage. Unless there is a mapping to a file, a virtual page does not exist. That mapping remains fixed for the life of the process.

The virtual memory on disk gets mapped to physical memory when available.

The kernel maintains some data structure (e.g. a bitmap) to indicate the free areas of the page file and other structures to maintain the mapping of logical addresses to the files.

Upvotes: 1

Related Questions