c - Implementing LRU algorithm -


i trying implement lru algorithm, not sure how change fifo lru , manipulate page table in

//the declared parameters follows:  pt_entry pte[max_page];        /* page table */  int mem_size;          /* physical memory size in page frames */  list free_list_head;       /* free list */   list res_set_head;         /* resident set */  int total_fault = 0;       /* total number of page faults */  int total_ref = 0;         /* total number of memory references */   unsigned short find_victim()  { unsigned short frame; list current;  frame = res_set_head->next->frame;   invalidate(frame);  current = res_set_head->next; res_set_head->next = current->next; res_set_head->next->prev = res_set_head; to_resident_set(current);  return frame;  }     //-----------------------------------------------------------------   void resolve(int address)   { unsigned short frame_alloc; int virt_page; static int disp_counter = 0;  virt_page = address >> 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 implement lru change resolve() routine unconditionally move pte[virt_page].frame bottom of resident set list, last evicted when new frame needed.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -