Avoid paging out pages on the first attempt if a page is used in the current frame or previous frame.

This commit is contained in:
aignacio_sf 2007-05-22 02:30:11 +00:00
parent 16d3fd7dad
commit 99ab24614f

View File

@ -808,7 +808,7 @@ void Lru::update_lru_page_old (LruPage *lru_page)
if(this->_m.total_lru_page_priority_changes if(this->_m.total_lru_page_priority_changes
< FRAME_MAXIMUM_PRIORITY_CHANGES) { < FRAME_MAXIMUM_PRIORITY_CHANGES) {
this->_m.lru_page_priority_change_array this->_m.lru_page_priority_change_array
[this->_m.total_lru_page_priority_changes ]= lru_page; [this->_m.total_lru_page_priority_changes]= lru_page;
this->_m.total_lru_page_priority_changes++; this->_m.total_lru_page_priority_changes++;
} }
} }
@ -1016,6 +1016,9 @@ bool Lru::page_out_lru (int memory_required)
do { do {
int index; int index;
int minimum_frame_identifier;
minimum_frame_identifier = this->_m.current_frame_identifier - 1;
// page out lower priority pages first // page out lower priority pages first
for(index = LPP_PageOut - 1; index >= 0; index--) { for(index = LPP_PageOut - 1; index >= 0; index--) {
@ -1026,6 +1029,10 @@ bool Lru::page_out_lru (int memory_required)
while(lru_page) { while(lru_page) {
next_lru_page = lru_page->_m.next; next_lru_page = lru_page->_m.next;
if(attempts == 0 && (lru_page->_m.current_frame_identifier >= minimum_frame_identifier)) {
// avoid swapping out pages used in the current and last frame on the first attempt
}
else {
if(lru_page->_m.v.lock == false && lru_page->_m.v.in_cache) { if(lru_page->_m.v.lock == false && lru_page->_m.v.in_cache) {
memory_required -= lru_page->_m.size; memory_required -= lru_page->_m.size;
this->_m.available_memory += lru_page->_m.size; this->_m.available_memory += lru_page->_m.size;
@ -1043,6 +1050,7 @@ bool Lru::page_out_lru (int memory_required)
break; break;
} }
} }
}
lru_page = next_lru_page; lru_page = next_lru_page;
} }
@ -1053,8 +1061,6 @@ bool Lru::page_out_lru (int memory_required)
} }
if(memory_required > 0) { if(memory_required > 0) {
// WARNING: pages could not be freed, all pages unlocked
this->unlock_all_pages( );
state = false; state = false;
} }
else { else {