1. Paging memory management overcomes the drawbacks of the switching system: external fragments, programs cannot be larger than physical memory, and so on. But the price paid is the page replacement. Under the switching system, a program is loaded into memory as a whole, so that, while the program is running, there is no need to load anything from disk, and all the pages of a program are not necessarily in memory under the paging system, so there may be a page break. The service program that breaks the page fault is responsible for loading the data on disk into physical memory, and if there are free pages in physical memory, use the free pages directly, but if the physical memory is full, you need to pick a page that has already been used to replace it. There is a question here, how to choose?
2. If the selected page is a page that will be visited soon thereafter, then the system will soon have to be interrupted again, which is very inappropriate. The goal of a page change is to reduce the number or probability of subsequent pages being interrupted. Therefore, the page that we select should be a page that will not be visited for a considerable amount of time, preferably in a page that will not be visited. If possible, we should also select a page that has not been modified, so that the replacement will not have to write the contents of the replaced page back to the disk, thus further speeding up the response of the fault pages.
3. What is the algorithm for page replacement?
1) Fairness algorithm: Stochastic algorithm, first come first out algorithm, Second chance algorithm, clock algorithm.
2) Non-fairness algorithm: Optimal algorithm, NRU algorithm, LRU algorithm, working set algorithm.
4. First come first out algorithm: replace the first to enter the memory of the page, the implementation mechanism is to use the linked list of all the pages in memory in the morning and evening to connect, and then every time the chain header page, the new incoming page hangs at the end of the list.
5. Second Chance algorithm: since FIFO only takes into memory time, does not care about how often a page is accessed, it may replace a page that is often accessed. The improvement is that when you replace a page with a FIFO, you need to see if the page is recently accessed, if it has not been accessed, is replaced directly, if recently accessed, the page is hung to the end of the list, and the time the page enters memory is set to the current time and its access is zeroed.
6. Clock algorithm:
7.NRU (not recently used) recently unused algorithm: Select a page that has not been visited in the most recent time to replace it, taking advantage of page access and modification bits.
8.LRU (Least recently used) Recently used the least algorithm: Consider not only the recent use, but also the most recently used frequency. It is implemented by means of a page-table method, a chain-table method, a matrix method, a shift register method.
9. The working set algorithm is used more in the actual operation system.
Paging memory management for the operating system 2