|
@@ -689,127 +689,6 @@ void Lru::update_lru_page (LruPage *lru_page)
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void Lru::update_lru_page_old (LruPage *lru_page)
|
|
void Lru::update_lru_page_old (LruPage *lru_page)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
-#if LRU_UNIT_TEST
|
|
|
|
|
- if(false) {
|
|
|
|
|
- char string[256];
|
|
|
|
|
-
|
|
|
|
|
- sprintf(string, " UPDATE %d\n", lru_page->_m.identifier);
|
|
|
|
|
- OutputDebugString(string);
|
|
|
|
|
- }
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- if(lru_page->_m.v.lock == false) {
|
|
|
|
|
- int delta_priority;
|
|
|
|
|
-
|
|
|
|
|
- delta_priority = 0;
|
|
|
|
|
- if(false && lru_page->_m.total_usage > 0) {
|
|
|
|
|
- int lifetime_frames;
|
|
|
|
|
-
|
|
|
|
|
- lifetime_frames = this->_m.current_frame_identifier -
|
|
|
|
|
- lru_page->_m.first_frame_identifier;
|
|
|
|
|
- if(lifetime_frames >= 10) {
|
|
|
|
|
- float one_over_update_frames;
|
|
|
|
|
-
|
|
|
|
|
- if(lru_page->_m.update_frame_identifier) {
|
|
|
|
|
- int target_priority;
|
|
|
|
|
- int integer_update_frames;
|
|
|
|
|
- float update_frames;
|
|
|
|
|
- float update_average_frame_utilization;
|
|
|
|
|
- float average_frame_bandwidth_utilization;
|
|
|
|
|
-
|
|
|
|
|
- integer_update_frames = (this->_m.current_frame_identifier -
|
|
|
|
|
- lru_page->_m.update_frame_identifier);
|
|
|
|
|
- if(integer_update_frames > 0) {
|
|
|
|
|
- update_frames = ( float ) integer_update_frames;
|
|
|
|
|
- one_over_update_frames = 1.0f / update_frames;
|
|
|
|
|
-
|
|
|
|
|
- update_average_frame_utilization =
|
|
|
|
|
- (float) (lru_page->_m.update_total_usage) *
|
|
|
|
|
- one_over_update_frames;
|
|
|
|
|
-
|
|
|
|
|
- lru_page->_m.average_frame_utilization =
|
|
|
|
|
- calculate_exponential_moving_average (
|
|
|
|
|
- update_average_frame_utilization, this->_m.weight,
|
|
|
|
|
- lru_page->_m.average_frame_utilization);
|
|
|
|
|
-
|
|
|
|
|
- average_frame_bandwidth_utilization =
|
|
|
|
|
- lru_page->_m.average_frame_utilization *
|
|
|
|
|
- lru_page->_m.size;
|
|
|
|
|
-
|
|
|
|
|
- target_priority = (int) (average_frame_bandwidth_utilization *
|
|
|
|
|
- this->_m.frame_bandwidth_factor);
|
|
|
|
|
-
|
|
|
|
|
- target_priority = (LPP_TotalPriorities - 1) - target_priority;
|
|
|
|
|
- if(target_priority < 0) {
|
|
|
|
|
- target_priority = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if(target_priority >= LPP_TotalPriorities) {
|
|
|
|
|
- target_priority = LPP_TotalPriorities - 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- delta_priority = target_priority - lru_page->_m.priority;
|
|
|
|
|
- lru_page->change_priority(delta_priority);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- lru_page->_m.update_frame_identifier =
|
|
|
|
|
- this->_m.current_frame_identifier;
|
|
|
|
|
-
|
|
|
|
|
- lru_page->_m.update_total_usage = 0;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(delta_priority == 0) {
|
|
|
|
|
- if(this->_m.current_frame_identifier
|
|
|
|
|
- == lru_page->_m.current_frame_identifier) {
|
|
|
|
|
- // page used during this frame twice or more =>
|
|
|
|
|
- // increase priority
|
|
|
|
|
- if(lru_page->_m.current_frame_usage >= 2) {
|
|
|
|
|
- if(lru_page->_m.priority >= LPP_High) {
|
|
|
|
|
- lru_page->change_priority(-2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(lru_page->_m.total_frame_page_faults >= 1) {
|
|
|
|
|
- // multiple page faults this frame => increase priority
|
|
|
|
|
- if(lru_page->_m.total_frame_page_faults >= 2) {
|
|
|
|
|
- if(lru_page->_m.priority >= LPP_High) {
|
|
|
|
|
- lru_page->change_priority(-2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- // single page faults this frame => increase priority
|
|
|
|
|
- if(lru_page->_m.priority >= LPP_High) {
|
|
|
|
|
- lru_page->change_priority(-1);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- // page not used this frame
|
|
|
|
|
- int last_access_delta;
|
|
|
|
|
-
|
|
|
|
|
- last_access_delta
|
|
|
|
|
- = this->_m.current_frame_identifier
|
|
|
|
|
- - lru_page->_m.current_frame_identifier;
|
|
|
|
|
- if(last_access_delta > 1) {
|
|
|
|
|
- if(lru_page->_m.priority < LPP_Low) {
|
|
|
|
|
- lru_page->change_priority(+1);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(lru_page->_m.priority_change) {
|
|
|
|
|
- if(this->_m.total_lru_page_priority_changes
|
|
|
|
|
- < FRAME_MAXIMUM_PRIORITY_CHANGES) {
|
|
|
|
|
- this->_m.lru_page_priority_change_array
|
|
|
|
|
- [this->_m.total_lru_page_priority_changes]= lru_page;
|
|
|
|
|
- this->_m.total_lru_page_priority_changes++;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|