X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=solutions%2Fp1.patch;h=fbfb405b09a090df9889f5b279c6947c1a43756c;hb=f242d3f31c84c5a045b980b07745a364d7301a6d;hp=ae8f15b9fec458b0b01e3cc47d13d7532c56237c;hpb=71b4d5a453498d45ae5929b51247a487c0e3719d;p=pintos-anon diff --git a/solutions/p1.patch b/solutions/p1.patch index ae8f15b..fbfb405 100644 --- a/solutions/p1.patch +++ b/solutions/p1.patch @@ -333,7 +333,7 @@ diff -u src/threads/synch.c~ src/threads/synch.c + const struct semaphore_elem *b + = list_entry (b_, struct semaphore_elem, elem); + -+ return a->thread->priority > b->thread->priority; ++ return a->thread->priority < b->thread->priority; +} + /* If any threads are waiting on COND (protected by LOCK), then @@ -364,11 +364,11 @@ diff -u src/threads/thread.c~ src/threads/thread.c +#include "threads/init.h" #include "threads/interrupt.h" #include "threads/intr-stubs.h" - #include "threads/mmu.h" #include "threads/palloc.h" #include "threads/switch.h" #include "threads/synch.h" +#include "devices/timer.h" + #include "threads/vaddr.h" #ifdef USERPROG #include "userprog/process.h" #endif @@ -494,7 +494,7 @@ diff -u src/threads/thread.c~ src/threads/thread.c + /* Add to run queue. */ thread_unblock (t); -+ if (priority < thread_get_priority ()) ++ if (priority > thread_get_priority ()) + thread_yield (); return tid; @@ -513,7 +513,7 @@ diff -u src/threads/thread.c~ src/threads/thread.c + const struct thread *a = list_entry (a_, struct thread, elem); + const struct thread *b = list_entry (b_, struct thread, elem); + -+ return a->priority > b->priority; ++ return a->priority < b->priority; +} + /* Transitions a blocked thread T to the ready-to-run state. @@ -614,7 +614,7 @@ diff -u src/threads/thread.c~ src/threads/thread.c + const struct thread *a = list_entry (a_, struct thread, donor_elem); + const struct thread *b = list_entry (b_, struct thread, donor_elem); + -+ return a->priority > b->priority; ++ return a->priority < b->priority; +} + +/* Recomputes T's priority in terms of its normal priority and @@ -625,10 +625,10 @@ diff -u src/threads/thread.c~ src/threads/thread.c +{ + int old_priority = t->priority; + int default_priority = t->normal_priority; -+ int donation = PRI_MAX; ++ int donation = PRI_MIN; + if (enable_mlfqs) + { -+ default_priority = fix_round (t->recent_cpu) / 4 + t->nice * 2; ++ default_priority = PRI_MAX - fix_round (t->recent_cpu) / 4 - t->nice * 2; + if (default_priority < PRI_MIN) + default_priority = PRI_MIN; + else if (default_priority > PRI_MAX) @@ -637,8 +637,8 @@ diff -u src/threads/thread.c~ src/threads/thread.c + if (!list_empty (&t->donors)) + donation = list_entry (list_max (&t->donors, donated_lower_priority, NULL), + struct thread, donor_elem)->priority; -+ t->priority = donation < default_priority ? donation : default_priority; -+ if (t->priority < old_priority && t->donee != NULL) ++ t->priority = donation > default_priority ? donation : default_priority; ++ if (t->priority > old_priority && t->donee != NULL) + thread_recompute_priority (t->donee); +} + @@ -654,7 +654,7 @@ diff -u src/threads/thread.c~ src/threads/thread.c + struct thread *max = list_entry (list_max (&ready_list, + thread_lower_priority, NULL), + struct thread, elem); -+ if (max->priority < cur->priority) ++ if (max->priority > cur->priority) + thread_yield (); + } + intr_set_level (old_level);