forked from sysudengle/OS_Page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfifo.c
41 lines (30 loc) · 793 Bytes
/
fifo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <getopt.h>
#include <stdlib.h>
#include "pagetable.h"
extern int memsize;
extern int debug;
extern struct frame *coremap;
static int to_go = -1;
/* Page to evict is chosen using the fifo algorithm.
* Returns the page frame number (which is also the index in the coremap)
* for the page that is to be evicted.
*/
int fifo_evict() {
to_go = (to_go + 1) % memsize;
return to_go;
}
/* This function is called on each access to a page to update any information
* needed by the fifo algorithm.
* Input: The page table entry for the page that is being accessed.
*/
void fifo_ref(pgtbl_entry_t *p) {
return;
}
/* Initialize any data structures needed for this
* replacement algorithm
*/
void fifo_init() {
}