In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use java to achieve the best replacement Optimal algorithm in the operating system, the article is very detailed, has a certain reference value, interested friends must read it!
Swap instruction
The optimal permutation algorithm is a theoretical algorithm proposed by Belady in 1966. The obsolete page it chooses will never be used in the future, perhaps the page that will no longer be accessed for the longest (future) time. The use of the best replacement algorithm usually ensures that the lowest page missing rate is obtained. However, at present, people are unable to compare with it, among several pages in memory, which page will no longer be accessed in the longest time in the future, so the algorithm can not be implemented, but it can be used to evaluate other algorithms. This is explained now as follows.
Suppose the system assigns three physical blocks to a process, and consider the following page number reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
When the process is running, the first three pages will be installed in memory, and the missing page will be interrupted when page 2 needs to be accessed later. At this point, OS will eliminate page 7 according to the best algorithm replacement algorithm. This is because page 0 will be the fifth page to be visited, page 1 will be the 14th page to be visited, page 7 will need to be introduced at a low rate of 18 visits, and so on.
The following is the source code implementation section:
Package chapter02;public class P175Optimal {/ / find out if the index public static int existEmpty (int [] place) {for (int I = 0; I < place I +) {if (place [I] = =-1) return I;} / / is not empty return-1;} / / find whether the element exists in the array public static boolean paramExist (int [] place,int param) {for (place I = 0; I < place.length) {for (place I = 0; I < place.length) Return true; +) {if (place [I] = = param) return true;} / / not empty return false;} / / get the maximum distance value public static int getMaxIndexOfNeed (int [] place,int [] block,int start) {/ / recent demand location int minBlockIndex =-1; int minPlaceIndex =-1; for (int PlaceIndex = 0 position PlaceIndex)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.