Fix Bug: Initialise the mmap table for the newly created thread rather than the current thread
This commit is contained in:
@@ -278,7 +278,7 @@ thread_create (const char *name, int priority,
|
||||
#endif
|
||||
|
||||
#ifdef VM
|
||||
mmap_init ();
|
||||
mmap_init (t);
|
||||
#endif
|
||||
|
||||
/* Prepare thread for first run by initializing its stack.
|
||||
|
||||
@@ -6,11 +6,11 @@ static bool mmap_less (const struct hash_elem *a_, const struct hash_elem *b_,
|
||||
void *aux);
|
||||
static void mmap_cleanup(struct hash_elem *e, void *aux);
|
||||
|
||||
/* Initializes the mmap table for the current thread. Sets the counter to 0. */
|
||||
/* Initializes the mmap table for the given thread, setting the mmap counter to
|
||||
0 and initializing the hash table. */
|
||||
bool
|
||||
mmap_init (void)
|
||||
mmap_init (struct thread *t)
|
||||
{
|
||||
struct thread *t = thread_current ();
|
||||
t->mmap_counter = 0;
|
||||
return hash_init (&t->mmap_files, mmap_hash, mmap_less, NULL);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ struct mmap_entry {
|
||||
struct hash_elem elem; /* An elem for the hash table. */
|
||||
};
|
||||
|
||||
bool mmap_init (void);
|
||||
bool mmap_init (struct thread *t);
|
||||
struct mmap_entry *mmap_insert (struct file *file, void *upage);
|
||||
void mmap_destroy (void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user