projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add warnings for missing disks with various projects.
[pintos-anon]
/
src
/
userprog
/
exception.c
diff --git
a/src/userprog/exception.c
b/src/userprog/exception.c
index f31f7a884a323b12b48c6c598d1fa6689fc57fa3..8b2e8b641adf7b90168b7b3ff4b3ae81e2bf4d6c 100644
(file)
--- a/
src/userprog/exception.c
+++ b/
src/userprog/exception.c
@@
-5,6
+5,9
@@
#include "threads/interrupt.h"
#include "threads/thread.h"
#include "threads/interrupt.h"
#include "threads/thread.h"
+/* Number of page faults processed. */
+static long long page_fault_cnt;
+
static void kill (struct intr_frame *);
static void page_fault (struct intr_frame *);
static void kill (struct intr_frame *);
static void page_fault (struct intr_frame *);
@@
-54,6
+57,13
@@
exception_init (void)
intr_register (14, 0, INTR_OFF, page_fault, "#PF Page-Fault Exception");
}
intr_register (14, 0, INTR_OFF, page_fault, "#PF Page-Fault Exception");
}
+/* Prints exception statistics. */
+void
+exception_print_stats (void)
+{
+ printf ("Exception: %lld page faults\n", page_fault_cnt);
+}
+
/* Handler for an exception (probably) caused by a user process. */
static void
kill (struct intr_frame *f)
/* Handler for an exception (probably) caused by a user process. */
static void
kill (struct intr_frame *f)
@@
-129,6
+139,9
@@
page_fault (struct intr_frame *f)
be assured of reading CR2 before it changed). */
intr_enable ();
be assured of reading CR2 before it changed). */
intr_enable ();
+ /* Count page faults. */
+ page_fault_cnt++;
+
/* Determine cause. */
not_present = (f->error_code & PF_P) == 0;
write = (f->error_code & PF_W) != 0;
/* Determine cause. */
not_present = (f->error_code & PF_P) == 0;
write = (f->error_code & PF_W) != 0;