projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
The lock functions don't really need to disable interrupts themselves,
[pintos-anon]
/
solutions
/
p1.patch
diff --git
a/solutions/p1.patch
b/solutions/p1.patch
index 213e05ef29e2f749ab24ad6f5a38e02b7d0ca630..ae8f15b9fec458b0b01e3cc47d13d7532c56237c 100644
(file)
--- a/
solutions/p1.patch
+++ b/
solutions/p1.patch
@@
-236,10
+236,16
@@
diff -u src/threads/synch.c~ src/threads/synch.c
intr_set_level (old_level);
}
intr_set_level (old_level);
}
-@@ -200,6 +218,23 @@ lock_acquire (struct lock *lock)
+@@ -200,8 +218,29 @@ lock_acquire (struct lock *lock)
+ lock_acquire (struct lock *lock)
+ {
++ enum intr_level old_level;
++
+ ASSERT (lock != NULL);
+ ASSERT (!intr_context ());
ASSERT (!lock_held_by_current_thread (lock));
ASSERT (!lock_held_by_current_thread (lock));
-
old_level = intr_disable ();
+
+
old_level = intr_disable ();
+
+ if (lock->holder != NULL)
+ {
+
+ if (lock->holder != NULL)
+ {
@@
-259,18
+265,18
@@
diff -u src/threads/synch.c~ src/threads/synch.c
+
sema_down (&lock->semaphore);
lock->holder = thread_current ();
+
sema_down (&lock->semaphore);
lock->holder = thread_current ();
-
intr_set_level (old_level);
-@@ -238,
13
+273,37 @@ void
+
+
intr_set_level (old_level);
+@@ -238,
9
+273,37 @@ void
lock_release (struct lock *lock)
{
lock_release (struct lock *lock)
{
-
enum intr_level old_level;
+
+
enum intr_level old_level;
+ struct thread *t = thread_current ();
+ struct list_elem *e;
+ struct thread *t = thread_current ();
+ struct list_elem *e;
-
++
ASSERT (lock != NULL);
ASSERT (lock_held_by_current_thread (lock));
ASSERT (lock != NULL);
ASSERT (lock_held_by_current_thread (lock));
-
old_level = intr_disable ();
+
+
old_level = intr_disable ();
+
+ /* Return donations to threads that want this lock. */
+ for (e = list_begin (&t->donors); e != list_end (&t->donors); )
+
+ /* Return donations to threads that want this lock. */
+ for (e = list_begin (&t->donors); e != list_end (&t->donors); )
@@
-295,7
+301,7
@@
diff -u src/threads/synch.c~ src/threads/synch.c
+ thread_recompute_priority (t);
+ thread_yield_to_higher_priority ();
+
+ thread_recompute_priority (t);
+ thread_yield_to_higher_priority ();
+
-
intr_set_level (old_level);
+
+
intr_set_level (old_level);
}
@@ -264,6 +323,7 @@ struct semaphore_elem
}
@@ -264,6 +323,7 @@ struct semaphore_elem