太原理工大学操作系统实验报告2016 下载本文

}

PAGETABLE *newPage; static int id = 99; static int blockId = -1; id++; blockId++; if (blockId == 4)

blockId = 0;

newPage = (PAGETABLE *)malloc(sizeof(PAGETABLE)); if (newPage != NULL) { } else

cout << \没有内存足够的空间为页表分配!\ << endl; newPage->address = id; newPage->page = -1; newPage->block = blockId; newPage->next = NULL; pushback_Page(pt, newPage);

void pushback_Page(PAGETABLE *queue, PAGETABLE *item) { }

void print(PAGETABLE *ptr) {

PAGETABLE *temp;

PAGETABLE *previous, *current; previous = queue; current = queue->next; while (current != NULL) { }

previous->next = item;

previous = current; current = current->next;

}

temp = ptr->next;

cout << \页号 \ << \块号 \ << endl; while (temp != NULL) { }

cout << \ << temp->page << \ << temp->block << endl; temp = temp->next;

void run(int num) {

int universal;

PAGETABLE *previous, *current;

index = work[num] / 10;//程序所在的页号 offset = work[num] % 10;//页内的位移量 previous = pt;

current = previous->next;

while (current != NULL && current->page != index) { }

if (current == NULL) {

cout << \作业\ << num << \没有在内存,发生缺页中断\ << endl; count1++;

if (is_LRU == false)//FIFO算法 { }

else//LRU算法 { }

find_LRU(); find_FIFO(); previous = current; current = current->next;

}

} else { }

if (is_LRU == false)//FIFO算法 { } else { }

if (current->next == NULL) { } else { }

PAGETABLE *temp, *ptr; temp = current;

previous->next = current->next; ptr = pt->next;

while (ptr->next != NULL) { }

ptr->next = temp; temp->next = NULL;

universal = first_memory + (temp->block) * 10 + offset;

cout << \作业\ << num << \所在内存的物理地址为 \ << universal << endl;

ptr = ptr->next;

universal = first_memory + (current->block) * 10 + offset;

cout << \作业\ << num << \所在内存的物理地址为 \ << universal << endl; universal = first_memory + (current->block) * 10 + offset;

cout << \作业\ << num << \所在内存的物理地址为 \ << universal << endl;

五、结果:

(1)先进先出算法FIFO: