fix: invert result of file_compare for shared_file_less
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "page.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "filesys/file.h"
|
||||
#include "filesys/filesys.h"
|
||||
#include "threads/malloc.h"
|
||||
#include "threads/palloc.h"
|
||||
#include "threads/vaddr.h"
|
||||
@@ -77,22 +77,18 @@ page_get (void *upage)
|
||||
bool
|
||||
page_load (struct page_entry *page, bool writable)
|
||||
{
|
||||
printf ("WE IN PAGE LOAD NOW %p %d\n", page->file, page->offset);
|
||||
/* If the page is read-only, we want to check if it is a shared page already
|
||||
loaded into memory. If it is, we can just map the page to the frame. */
|
||||
if (!page->writable && !writable)
|
||||
{
|
||||
printf ("Hi 0! %d %d\n", page->offset, file_length (page->file));
|
||||
struct shared_page_entry *shared_page =
|
||||
shared_page_get (page->file, page->upage);
|
||||
|
||||
if (shared_page != NULL)
|
||||
{
|
||||
printf ("Hi 0.1!\n");
|
||||
/* Map the page to the shared frame for this read-only portion. */
|
||||
if (!install_page (page->upage, shared_page->frame, false))
|
||||
return false;
|
||||
printf ("Hi 0.2!\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -108,11 +104,9 @@ page_load (struct page_entry *page, bool writable)
|
||||
if (!install_page (page->upage, frame, page->writable))
|
||||
{
|
||||
frame_free (frame);
|
||||
printf ("Hi 2!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
printf ("UR MAMA SO FAT");
|
||||
/* Move the file pointer to the correct location in the file. Then, read the
|
||||
data from the file into the frame. Checks that we were able to read the
|
||||
expected number of bytes. */
|
||||
@@ -120,7 +114,6 @@ page_load (struct page_entry *page, bool writable)
|
||||
if (file_read (page->file, frame, page->read_bytes) != (int) page->read_bytes)
|
||||
{
|
||||
frame_free (frame);
|
||||
printf ("Hi 3!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,7 +126,6 @@ page_load (struct page_entry *page, bool writable)
|
||||
if (shared_page_insert (page->file, page->upage, frame) == NULL)
|
||||
{
|
||||
frame_free (frame);
|
||||
printf ("Hi 4!\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +160,7 @@ shared_file_less (const struct hash_elem *a_, const struct hash_elem *b_,
|
||||
const struct shared_file_entry *b = hash_entry (b_, struct shared_file_entry,
|
||||
elem);
|
||||
|
||||
return file_compare (a->file, b->file);
|
||||
return !file_compare (a->file, b->file);
|
||||
}
|
||||
|
||||
/* Hashing function needed for the shared pages table. Returns a hash for an
|
||||
|
||||
Reference in New Issue
Block a user