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 179 additions and 12 deletions
Showing only changes of commit dae5b0d097 - Show all commits

View File

@@ -68,8 +68,7 @@ sema_down (struct semaphore *sema)
old_level = intr_disable ();
while (sema->value == 0)
{
list_insert_ordered(&sema->waiters, &thread_current ()->elem,
priority_more, NULL);
list_push_back (&sema->waiters, &thread_current ()->elem);
thread_block ();
}
sema->value--;
@@ -115,8 +114,11 @@ sema_up (struct semaphore *sema)
old_level = intr_disable ();
if (!list_empty (&sema->waiters))
thread_unblock (list_entry (list_pop_front (&sema->waiters),
struct thread, elem));
{
struct list_elem *e = list_min (&sema->waiters, priority_more, NULL);
list_remove (e);
thread_unblock (list_entry (e, struct thread, elem));
}
sema->value++;
intr_set_level (old_level);