projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean some more files.
[pintos-anon]
/
solutions
/
p1.patch
diff --git
a/solutions/p1.patch
b/solutions/p1.patch
index ce21107889227b3c51d0290c40da6f81a8416421..a3079163a4f1c1f336061f980eacc968b656df57 100644
(file)
--- a/
solutions/p1.patch
+++ b/
solutions/p1.patch
@@
-1,6
+1,7
@@
+Index: src/devices/timer.c
diff -u src/devices/timer.c~ 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;
@@ -23,6 +23,9 @@ static volatile int64_t ticks;
Initialized by timer_calibrate(). */
static unsigned loops_per_tick;
@@
-60,7
+61,7
@@
diff -u src/devices/timer.c~ src/devices/timer.c
}
/* Suspends execution for approximately MS milliseconds. */
}
/* Suspends execution for approximately MS milliseconds. */
-@@ -132,6 +158,1
6
@@ timer_interrupt (struct intr_frame *args
+@@ -132,6 +158,1
7
@@ timer_interrupt (struct intr_frame *args
{
ticks++;
thread_tick ();
{
ticks++;
thread_tick ();
@@
-72,14
+73,16
@@
diff -u src/devices/timer.c~ src/devices/timer.c
+ if (ticks < t->wakeup_time)
+ break;
+ sema_up (&t->timer_sema);
+ if (ticks < t->wakeup_time)
+ break;
+ sema_up (&t->timer_sema);
++ thread_yield_to_higher_priority ();
+ list_pop_front (&wait_list);
+ }
}
/* Returns true if LOOPS iterations waits for more than one timer
+ list_pop_front (&wait_list);
+ }
}
/* 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
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
@@ -0,0 +1,120 @@
+#ifndef THREADS_FIXED_POINT_H
+#define THREADS_FIXED_POINT_H
@@
-201,9
+204,10
@@
diff -u src/threads/fixed-point.h~ src/threads/fixed-point.h
+}
+
+#endif /* threads/fixed-point.h */
+}
+
+#endif /* threads/fixed-point.h */
+Index: src/threads/synch.c
diff -u src/threads/synch.c~ 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);
@@ -114,10 +114,28 @@ sema_up (struct semaphore *sema)
ASSERT (sema != NULL);
@@
-354,9
+358,10
@@
diff -u src/threads/synch.c~ src/threads/synch.c
}
/* Wakes up all threads, if any, waiting on COND (protected by
}
/* 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
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>
@@ -5,12 +5,14 @@
#include <stdio.h>
#include <string.h>
@@
-364,11
+369,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/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/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
#ifdef USERPROG
#include "userprog/process.h"
#endif
@@
-413,7
+418,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
- /* Enforce preemption. */
- if (++thread_ticks >= TIME_SLICE)
- intr_yield_on_return ();
- /* Enforce preemption. */
- if (++thread_ticks >= TIME_SLICE)
- intr_yield_on_return ();
-+ if (
enable
_mlfqs)
++ if (
thread
_mlfqs)
+ {
+ /* Update load average. */
+ if (timer_ticks () % TIMER_FREQ == 0)
+ {
+ /* Update load average. */
+ if (timer_ticks () % TIMER_FREQ == 0)
@@
-451,7
+456,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
+ /* Switch threads if time slice has expired. */
+ if (++thread_ticks >= TIME_SLICE)
+ {
+ /* Switch threads if time slice has expired. */
+ if (++thread_ticks >= TIME_SLICE)
+ {
-+ if (
enable
_mlfqs)
++ if (
thread
_mlfqs)
+ thread_recompute_priority (thread_current ());
+ intr_yield_on_return ();
+ }
+ thread_recompute_priority (thread_current ());
+ intr_yield_on_return ();
+ }
@@
-476,7
+481,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
/* Initialize thread. */
- init_thread (t, name, priority);
/* Initialize thread. */
- init_thread (t, name, priority);
-+ init_thread (t, name,
enable
_mlfqs ? cur->priority : priority);
++ init_thread (t, name,
thread
_mlfqs ? cur->priority : priority);
tid = t->tid = allocate_tid ();
+ t->nice = cur->nice;
+ t->recent_cpu = cur->recent_cpu;
tid = t->tid = allocate_tid ();
+ t->nice = cur->nice;
+ t->recent_cpu = cur->recent_cpu;
@@
-547,7
+552,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
+thread_set_priority (int priority)
{
- thread_current ()->priority = new_priority;
+thread_set_priority (int priority)
{
- thread_current ()->priority = new_priority;
-+ if (!
enable
_mlfqs)
++ if (!
thread
_mlfqs)
+ {
+ struct thread *t = thread_current ();
+
+ {
+ struct thread *t = thread_current ();
+
@@
-557,7
+562,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
}
/* Returns the current thread's priority. */
}
/* Returns the current thread's priority. */
-@@ -298,33 +386,9
3
@@ thread_get_priority (void)
+@@ -298,33 +386,9
8
@@ thread_get_priority (void)
/* Sets the current thread's nice value to NICE. */
void
/* Sets the current thread's nice value to NICE. */
void
@@
-626,7
+631,7
@@
diff -u src/threads/thread.c~ src/threads/thread.c
+ int old_priority = t->priority;
+ int default_priority = t->normal_priority;
+ int donation = PRI_MIN;
+ int old_priority = t->priority;
+ int default_priority = t->normal_priority;
+ int donation = PRI_MIN;
-+ if (
enable
_mlfqs)
++ if (
thread
_mlfqs)
+ {
+ default_priority = PRI_MAX - fix_round (t->recent_cpu) / 4 - t->nice * 2;
+ if (default_priority < PRI_MIN)
+ {
+ default_priority = PRI_MAX - fix_round (t->recent_cpu) / 4 - t->nice * 2;
+ if (default_priority < PRI_MIN)
@@
-655,7
+660,12
@@
diff -u src/threads/thread.c~ src/threads/thread.c
+ thread_lower_priority, NULL),
+ struct thread, elem);
+ if (max->priority > cur->priority)
+ thread_lower_priority, NULL),
+ struct thread, elem);
+ if (max->priority > cur->priority)
-+ thread_yield ();
++ {
++ if (intr_context ())
++ intr_yield_on_return ();
++ else
++ thread_yield ();
++ }
+ }
+ intr_set_level (old_level);
}
+ }
+ intr_set_level (old_level);
}
@@
-690,9
+700,10
@@
diff -u src/threads/thread.c~ src/threads/thread.c
}
/* Completes a thread switch by activating the new thread's page
}
/* 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
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>
@@ -4,6 +4,8 @@
#include <debug.h>
#include <list.h>
@@
-724,7
+735,7
@@
diff -u src/threads/thread.h~ src/threads/thread.h
+ /* Alarm clock. */
+ int64_t wakeup_time; /* Time to wake this thread up. */
+ /* 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
+ struct semaphore timer_sema; /* Semaphore. */
+
#ifdef USERPROG