B5: Include "open by a process" as a reason to disallow removing a
[pintos-anon] / solutions / p1.patch
index ae8f15b9fec458b0b01e3cc47d13d7532c56237c..7f95cefc710642d29728eabf1b0e1b3df6ea7078 100644 (file)
@@ -1,6 +1,7 @@
+Index: src/devices/timer.c
 diff -u src/devices/timer.c~ src/devices/timer.c
---- src/devices/timer.c~ 2005-05-24 15:52:43.000000000 -0700
-+++ src/devices/timer.c 2005-05-26 15:19:20.000000000 -0700
+--- src/devices/timer.c~
++++ src/devices/timer.c
 @@ -23,6 +23,9 @@ static volatile int64_t ticks;
     Initialized by timer_calibrate(). */
  static unsigned loops_per_tick;
@@ -77,9 +78,10 @@ diff -u src/devices/timer.c~ src/devices/timer.c
  }
  
  /* Returns true if LOOPS iterations waits for more than one timer
+Index: src/threads/fixed-point.h
 diff -u src/threads/fixed-point.h~ src/threads/fixed-point.h
---- src/threads/fixed-point.h~ 1969-12-31 16:00:00.000000000 -0800
-+++ src/threads/fixed-point.h 2005-06-02 14:11:21.000000000 -0700
+--- src/threads/fixed-point.h~
++++ src/threads/fixed-point.h
 @@ -0,0 +1,120 @@
 +#ifndef THREADS_FIXED_POINT_H
 +#define THREADS_FIXED_POINT_H
@@ -201,9 +203,10 @@ diff -u src/threads/fixed-point.h~ src/threads/fixed-point.h
 +}
 +
 +#endif /* threads/fixed-point.h */
+Index: src/threads/synch.c
 diff -u src/threads/synch.c~ src/threads/synch.c
---- src/threads/synch.c~ 2005-05-24 20:47:28.000000000 -0700
-+++ src/threads/synch.c 2005-06-02 14:20:15.000000000 -0700
+--- src/threads/synch.c~
++++ src/threads/synch.c
 @@ -114,10 +114,28 @@ sema_up (struct semaphore *sema) 
    ASSERT (sema != NULL);
  
@@ -333,7 +336,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
@@ -354,9 +357,10 @@ diff -u src/threads/synch.c~ src/threads/synch.c
  }
  
  /* Wakes up all threads, if any, waiting on COND (protected by
+Index: src/threads/thread.c
 diff -u src/threads/thread.c~ src/threads/thread.c
---- src/threads/thread.c~ 2005-06-02 14:35:12.000000000 -0700
-+++ src/threads/thread.c 2005-06-02 14:55:56.000000000 -0700
+--- src/threads/thread.c~
++++ src/threads/thread.c
 @@ -5,12 +5,14 @@
  #include <stdio.h>
  #include <string.h>
@@ -364,11 +368,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 +498,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 +517,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 +618,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 +629,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 +641,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 +658,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);
@@ -690,9 +694,10 @@ diff -u src/threads/thread.c~ src/threads/thread.c
  }
  
  /* Completes a thread switch by activating the new thread's page
+Index: src/threads/thread.h
 diff -u src/threads/thread.h~ src/threads/thread.h
---- src/threads/thread.h~ 2005-06-02 14:32:36.000000000 -0700
-+++ src/threads/thread.h 2005-06-02 14:38:46.000000000 -0700
+--- src/threads/thread.h~
++++ src/threads/thread.h
 @@ -4,6 +4,8 @@
  #include <debug.h>
  #include <list.h>
@@ -724,7 +729,7 @@ diff -u src/threads/thread.h~ src/threads/thread.h
  
 +    /* Alarm clock. */
 +    int64_t wakeup_time;                /* Time to wake this thread up. */
-+    struct list_elem timer_elem;        /* Element in timer_wait_list. */
++    struct list_elem timer_elem;        /* Element in wait_list. */
 +    struct semaphore timer_sema;        /* Semaphore. */
 +
  #ifdef USERPROG