-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab6_hooks.c
114 lines (107 loc) · 3.12 KB
/
lab6_hooks.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "xinu.h"
extern int TEST;
extern unsigned int TEST5_PAGE;
extern unsigned char* TEST5_PTR;
extern unsigned char* TEST6_PTR;
extern int TEST5_pagefault;
extern int TEST6_pagefault;
void hook_ptable_create(unsigned int pagenum){
/*switch( TEST ){
case 5:
kprintf("GRADING : Test 5 creates a new page table at frame %d as expected\r\n", pagenum );
case 6:
kprintf("GRADING : Test 6 creates a new page table at frame %d as expected\r\n", pagenum );
break;
}*/
}
void hook_ptable_delete(unsigned int pagenum){
/*
switch( TEST ){
case 1:
case 2:
case 3:
case 4:
case 5:
kprintf("GRADING : page table %d is unexpectedly deleted in test %d \r\n", pagenum, TEST );
break;
case 51:
kprintf("GRADING : page table %d is deleted in test %d xmunmap() \r\n", pagenum, TEST );
break;
case 6:
kprintf("GRADING : page table %d is unexpectedly deleted in test %d \r\n", pagenum, TEST );
break;
case 61:
break;
case 62:
kprintf("GRADING : page table %d is deleted in test %d xmunmap() \r\n", pagenum, TEST );
break;
}
*/
}
void hook_pfault(char *addr){
/*
switch( TEST ){
case 5:
if( addr == TEST5_PTR ){
kprintf("GRADING : Test 5 cause page fault at address: 0x%0X as expected\r\n", addr);
TEST5_pagefault = 1;
}else{
TEST5_pagefault = 1;
kprintf("GRADING : Test 5 cause page fault at unexpected address: expect 0x%0X but instead 0x%0X\r\n", TEST5_PTR, addr);
}
break;
case 6:
if( addr == TEST6_PTR ){
kprintf("GRADING : Test 6 cause page fault at address: 0x%0X as expected\r\n", addr);
TEST6_pagefault = 1;
}else{
TEST6_pagefault = 1;
kprintf("GRADING : Test 6 cause page fault at unexpected address: expect 0x%0X but instead 0x%0X\r\n", TEST6_PTR, addr);
}
break;
case 61:
kprintf("GRADING : Test 6 failed because the new process accessing the memory location should not trigger a page fault.\r\n");
break;
case 12:
break;
case 13:
break;
default:
kprintf("page fault at an unknown test!\r\n");
break;
}
*/
}
extern int fifo_swap;
extern int ourpolicy_swap;
void hook_pswap_out(unsigned int pagenum, int framenb){
switch( TEST ){
/*case 1:
case 2:
case 3:
case 4:
case 5:
kprintf("GRADING : page %d is unexpectedly swapped out in test %d \r\n", pagenum, TEST );
break;
*/
case 10:
/** FIFO policy
* */
kprintf("GRADING : page %d is swapped out in test %d \r\n", pagenum, TEST );
fifo_swap++;
break;
case 11:
/** OURPOLICY
* it should have fewer page-outs than FIFO
* */
kprintf("GRADING : page %d is swapped out in test %d \r\n", pagenum, TEST );
ourpolicy_swap++;
break;
/*case 12:
kprintf("GRADING : page %d is swapped out in test %d \r\n", pagenum, TEST );
break;
case 13:
kprintf("GRADING : page %d is swapped out in test %d \r\n", pagenum, TEST );
break;*/
}
}