[Operating system] Operation System Chapter 6: page replacement algorithm

6.1 Optimal page replacement algorithm

(1) functional objectives
: When a page fault occurs, users need to move a new page and the memory is full, select among which physical memory pages to be replaced.
Goals: Minimize pages swapped out the number of times (that is, the number of missing pages interruption). The future is no longer used or less used pages short term swap out, usually only under the guidance of the principle of locality to be predicted based on past statistics.
Page locking (frame locking): used to describe the permanent memory must be a key part of the operating system or time-critical (time-critical) application process. To achieve this is to add lock flag (lock bit) in the page table.

(2) optimal page replacement algorithm
basic idea: When a page fault occurs, for each logical page stored in memory, calculated before its next visit, but also how long to wait, choose to wait time the longest that, as the replacement page.
However, this is an ideal situation, can not be achieved in practice, because the operating system can not know every page how long to wait until later be accessed again.
Used as a basis for evaluating the performance of other algorithms (to run a program on a simulator and record every page visits, you can use the optimal algorithm running in the second pass).

6.2 FIFO algorithm

6.3 Recent Least Recently Used algorithm

6.4 Clock page replacement algorithm

6.5 Secondary Opportunity Act

If it is a write operation, dirty bit is set to 1. Description This part of the data memory access is a write operation, and hard disk Uehara data is not the same, so be written to disk, if it is 0, did not write this part of memory operation, then that content on the memory and hard disk are the same, you can lose direct.
The purpose is to reduce the write operation to the hard disk.
If used and dirty bit is 0, then replaced; if one of them is 1, then this bit is set to 0, the pointer to go down; if we are all one, that first used to change to 0, indicating that there are 2 opportunity.

Full be supplemented
by reference
https://www.bilibili.com/video/av6538245?p=19

Published 29 original articles · won praise 19 · views 4438

Guess you like

Origin blog.csdn.net/iwanderu/article/details/103946369