c - Implemeting LRU algorithm -


I am trying to implement the LRU algorithm, although I do not really know how to change FIFA to LRU And Manipulate in the page table

  // The declared parameters are as follows: pt_entry pte [MAX_PAGE]; / * Page table * / int mmsizes; / * Physical memory size in page frame * / list free_list_head; / * Free list * / list res_set_head; / * Resident set * / int total_fault = 0; / * Total number of page defects * / int total_ref = 0; / * Total number of memory references * / unsigned short find_victim () {signed short frame; Current list; Frame = resize-size- & gt; Next-> Frame; Invalidate (frame); Current = res_set_head-> next; Res_set_head-> Next = current-> gt; Res_set_head-> Next-> Prev = res_set_head; To_resident_set (current); Return frame; } // ----------------------------------------------- ------------------ Zero resolution (full address) {unsigned short frame_loc; Int virt_page; Static Inter Dispatch = 0; Virt_page = Address & gt; & Gt; 8; If (pte [virt_page] .valid == 1) {} else {frame_alloc = find_frame (); Pte [virt_page]. Valid = 1; Pte [virt_page] .frame = frame_alloc; Total_fault ++; }}  

One way to implement LRU is to solve your () Resident set list in the lower part of the pte [virt_page] .frame routine, so that a new frame can be ejected if necessary.


Comments