fix: synchronise pagedir which now may be accessed by other threads, with a lock
This commit is contained in:
@@ -396,6 +396,7 @@ process_exit (void)
|
||||
|
||||
/* Destroy the current process's page directory and switch back
|
||||
to the kernel-only page directory. */
|
||||
lock_acquire (&cur->pagedir_lock);
|
||||
pd = cur->pagedir;
|
||||
if (pd != NULL)
|
||||
{
|
||||
@@ -410,6 +411,7 @@ process_exit (void)
|
||||
pagedir_activate (NULL);
|
||||
pagedir_destroy (pd);
|
||||
}
|
||||
lock_release (&cur->pagedir_lock);
|
||||
}
|
||||
|
||||
/* Destruct a process_result, with multi-thread awareness.
|
||||
@@ -535,7 +537,9 @@ load (const char *file_name, void (**eip) (void), void **esp)
|
||||
lock_acquire (&filesys_lock);
|
||||
|
||||
/* Allocate and activate page directory. */
|
||||
lock_acquire (&t->pagedir_lock);
|
||||
t->pagedir = pagedir_create ();
|
||||
lock_release (&t->pagedir_lock);
|
||||
if (t->pagedir == NULL)
|
||||
goto done;
|
||||
process_activate ();
|
||||
@@ -761,11 +765,16 @@ get_usr_kpage (enum palloc_flags flags, void *upage)
|
||||
void *page;
|
||||
#ifdef VM
|
||||
struct thread *t = thread_current ();
|
||||
lock_acquire (&t->pagedir_lock);
|
||||
if (pagedir_get_page (t->pagedir, upage) != NULL)
|
||||
return NULL;
|
||||
{
|
||||
lock_release (&t->pagedir_lock);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
page = frame_alloc (flags, upage, t);
|
||||
pagedir_set_accessed (t->pagedir, upage, true);
|
||||
lock_release (&t->pagedir_lock);
|
||||
#else
|
||||
page = palloc_get_page (flags | PAL_USER);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user