aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-04-26 14:03:39 -0600
committerJack Sangdahl <[email protected]>2024-04-26 14:03:39 -0600
commit2b26f1c4b3cd348f6fdd8a89e7a91ace2b486157 (patch)
tree7c3f9477e52db3ba3d93f9bdcebe5d9debf4742e
parentbb5488dff24b696341317f324b50882427afb155 (diff)
downloadcsci3753-2b26f1c4b3cd348f6fdd8a89e7a91ace2b486157.tar.gz
csci3753-2b26f1c4b3cd348f6fdd8a89e7a91ace2b486157.zip
pa8: tidy data types
-rw-r--r--pa8_predict/pager-predict.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/pa8_predict/pager-predict.c b/pa8_predict/pager-predict.c
index ff1a7aa..c0715d1 100644
--- a/pa8_predict/pager-predict.c
+++ b/pa8_predict/pager-predict.c
@@ -79,11 +79,10 @@ void insert_cfg(int curr_page, int proc, int prev_page,
}
void pageit(Pentry q[MAXPROCESSES]) {
- static bool initialized = false;
- static int tick = 1, time_stamps[MAXPROCESSES][MAXPROCPAGES],
- proc_stat[MAXPROCESSES], pc_prev[MAXPROCESSES];
+ static bool initialized = false, proc_active[MAXPROCESSES];
static struct page_stat cfg[MAXPROCESSES][MAXPROCPAGES][MAXPROCPAGES];
- int proc_tmp, page_tmp, lru_page, prev_page, curr_page;
+ static int proc_tmp, page_tmp, lru_page, prev_page, curr_page,
+ tick = 1, time_stamps[MAXPROCESSES][MAXPROCPAGES], pc_prev[MAXPROCESSES];
if (!initialized) {
for (int i = 0; i < MAXPROCESSES; i++)
for (int j = 0; j < MAXPROCESSES; j++)
@@ -95,15 +94,13 @@ void pageit(Pentry q[MAXPROCESSES]) {
for (proc_tmp = 0; proc_tmp < MAXPROCESSES; proc_tmp++) {
for (page_tmp = 0; page_tmp < MAXPROCPAGES; page_tmp++)
time_stamps[proc_tmp][page_tmp] = 0;
- proc_stat[proc_tmp] = 0;
+ proc_active[proc_tmp] = false;
}
initialized = true;
}
for (proc_tmp = 0; proc_tmp < MAXPROCESSES; proc_tmp++) {
if (!q[proc_tmp].active)
continue;
- if (prev_page == -1)
- continue;
prev_page = active_page(pc_prev[proc_tmp]);
pc_prev[proc_tmp] = q[proc_tmp].pc;
curr_page = active_page(q[proc_tmp].pc);
@@ -128,10 +125,10 @@ void pageit(Pentry q[MAXPROCESSES]) {
if (q[proc_tmp].pages[page_tmp] == 1)
continue;
if (pagein(proc_tmp, page_tmp)) {
- proc_stat[proc_tmp] = 0;
+ proc_active[proc_tmp] = false;
continue;
}
- if (proc_stat[proc_tmp])
+ if (proc_active[proc_tmp])
continue;
if (find_lru_page(time_stamps, q, proc_tmp, &lru_page))
continue;
@@ -139,7 +136,7 @@ void pageit(Pentry q[MAXPROCESSES]) {
fprintf(stderr, "error: failed to page out page %d\n", lru_page);
exit(EXIT_FAILURE);
}
- proc_stat[proc_tmp] = 1;
+ proc_active[proc_tmp] = true;
}
for (proc_tmp = 0; proc_tmp < MAXPROCESSES; proc_tmp++) {
struct page_stat *predictions;