Most Recently Used

Most Recently Used

A new feature of PeopleTools 8.50 is the horizontal navigation menu that runs across the top of the screen below the header. It means the menu down the left hand side is no longer needed. This new horizontal menu has a Favourites menu item, and on this it keeps track of the most recently accessed components you have navigated to. But it is capped at the last 5. Wouldn't it be great to increase this, to 10 maybe. The Most Recently Used items are set using the PT_HNAV_JS HTML Definition. Line 1474 has a CONSTANT called MAX_MRU which is set at 5 as delivered. Increase this to 10 (or more if you want) and voila, your Most Recently Used items increase to 10.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, here's the code: ```c++ #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { const int N = 54; // length of page access sequence const int M = 6; // number of main memory frames const int P = 19; // page number range (0-18) // generate page access sequence randomly vector<int> page_seq; for (int i = 0; i < N; ++i) { page_seq.push_back(rand() % P); } // LRU algorithm vector<int> frames(M, -1); // initialize all frames to -1 (empty) vector<int> page_fault_seq; // record page faults int page_faults = 0; for (int i = 0; i < N; ++i) { int page = page_seq[i]; auto it = find(frames.begin(), frames.end(), page); // check if page is already in memory if (it == frames.end()) { // page fault ++page_faults; if (frames[0] == -1) { // there is an empty frame frames[0] = page; } else { // no empty frame, need to evict the least recently used page int lru_page = frames.back(); // the last page in the frames is the LRU page frames.pop_back(); frames.insert(frames.begin(), page); // insert the new page at the front page_fault_seq.push_back(lru_page); } } else { // page hit frames.erase(it); frames.insert(frames.begin(), page); // move the page to the front } } // output results cout << "Page replacement sequence: "; for (auto p : page_fault_seq) { cout << p << " "; } cout << endl; cout << "Page fault rate: " << static_cast<double>(page_faults) / N << endl; return 0; } ``` Explanation: - We first generate a page access sequence of length 54 using a random function. We assume that the page number range is 0-18. - We then implement the LRU algorithm for page replacement on the above access sequence. We use a vector `frames` to represent the main memory frames, and initialize all frames to -1 (empty). We also use a vector `page_fault_seq` to record the page replacement sequence (i.e., the pages that are evicted from memory due to page faults). - For each page in the access sequence, we check if it is already in memory. If it is, we move it to the front of `frames` (since it is the most recently used page). If it is not, we check if there is an empty frame. If there is, we simply put the page in that frame. If there is not, we evict the least recently used page (which is the last page in `frames`), and put the new page in the front of `frames`. We also record the evicted page in `page_fault_seq`. - After processing the entire access sequence, we output the page replacement sequence and the page fault rate. Note that the page fault rate may vary each time you run the program due to the randomness of the page access sequence.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值