Merge 'task1/priority-donation' into 'master' #14

Merged
sb3923 merged 66 commits from task1/priority-donation into master 2024-10-23 16:15:45 +00:00
4 changed files with 271 additions and 16 deletions
Showing only changes of commit 6223846fde - Show all commits

View File

@@ -248,15 +248,16 @@ lock_acquire (struct lock *lock)
ASSERT (!lock_held_by_current_thread (lock)); ASSERT (!lock_held_by_current_thread (lock));
struct thread *t = thread_current (); struct thread *t = thread_current ();
enum intr_level old_level = intr_disable ();
/* TODO: If a high-priority thread holding a lock sleeps, this may cause a
race condition here or break the assumption that donation must occur. */
if (lock->holder != NULL) if (lock->holder != NULL)
{ {
t->waiting_lock = lock; t->waiting_lock = lock;
donate_priority (lock->holder); donate_priority (lock->holder);
} }
intr_set_level (old_level);
sema_down (&lock->semaphore); sema_down (&lock->semaphore);
lock->holder = thread_current (); lock->holder = thread_current ();
t->waiting_lock = NULL; t->waiting_lock = NULL;