-
Notifications
You must be signed in to change notification settings - Fork 0
/
rand.c
45 lines (36 loc) · 1.05 KB
/
rand.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
42
43
44
45
/*
* ============================================================================================
* File Name : rand.c
* Name : Seungkyu Kim
* Created Date : Oct.22.2015
* Modified Date : Oct.24.2015
*
* Copyright 2015 Seungkyu Kim all rights reserved
* ============================================================================================
*/
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <getopt.h>
#include <stdlib.h>
#include "sim.h"
#include "pagetable.h"
extern struct frame *coremap;
/* Page to evict is chosen using the rand algorithm.
* Returns the page frame number (which is also the index in the coremap)
* for the page that is to be evicted.
*/
int rand_evict() {
// choose index in coremap to evict a page from
int idx = (int)(random() % memsize);
return idx;
}
/* This function is called on each access to a page to update any information
* needed by the rand algorithm.
* Input: The page table entry for the page that is being accessed.
*/
void rand_ref(pgtbl_entry_t *p) {
return;
}
void rand_init() {
}