X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=solutions%2Fp1-2.patch;h=dfae038bbb4367526d07ebc9aaf5bd61c21f59de;hb=a9ca36e41805e259c2bfc238655a9586f7efb303;hp=b7e9c798f6674037242d2282e1c9e3cdd09404a5;hpb=74411dcc7652a3e8a05e0e04ae4add50c28dbe22;p=pintos-anon diff --git a/solutions/p1-2.patch b/solutions/p1-2.patch index b7e9c79..dfae038 100644 --- a/solutions/p1-2.patch +++ b/solutions/p1-2.patch @@ -1,6 +1,6 @@ -diff -X pat -urpN pintos.orig/src/threads/synch.c pintos/src/threads/synch.c ---- pintos.orig/src/threads/synch.c 2004-09-19 21:29:53.000000000 -0700 -+++ pintos/src/threads/synch.c 2004-09-27 16:50:14.000000000 -0700 +diff -X pat -urpN threads/synch.c! src/threads/synch.c +--- src/threads/synch.c~ 2004-09-19 21:29:53.000000000 -0700 ++++ src/threads/synch.c 2004-09-27 16:50:14.000000000 -0700 @@ -330,3 +330,35 @@ cond_name (const struct condition *cond) return cond->name; @@ -37,9 +37,9 @@ diff -X pat -urpN pintos.orig/src/threads/synch.c pintos/src/threads/synch.c + } + lock_release (&latch->monitor_lock); +} -diff -X pat -urpN pintos.orig/src/threads/synch.h pintos/src/threads/synch.h ---- pintos.orig/src/threads/synch.h 2004-09-19 21:29:53.000000000 -0700 -+++ pintos/src/threads/synch.h 2004-09-27 16:50:14.000000000 -0700 +diff -X pat -urpN src/threads/synch.h~ src/threads/synch.h +--- src/threads/synch.h~ 2004-09-19 21:29:53.000000000 -0700 ++++ src/threads/synch.h 2004-09-27 16:50:14.000000000 -0700 @@ -44,4 +44,16 @@ void cond_signal (struct condition *, st void cond_broadcast (struct condition *, struct lock *); const char *cond_name (const struct condition *); @@ -57,9 +57,9 @@ diff -X pat -urpN pintos.orig/src/threads/synch.h pintos/src/threads/synch.h +void latch_release (struct latch *); + #endif /* threads/synch.h */ -diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c ---- pintos.orig/src/threads/thread.c 2004-09-26 14:15:17.000000000 -0700 -+++ pintos/src/threads/thread.c 2004-09-27 16:51:03.000000000 -0700 +diff -X pat -urpN src/threads/thread.c~ src/threads/thread.c +--- src/threads/thread.c~ 2004-09-26 14:15:17.000000000 -0700 ++++ src/threads/thread.c 2004-09-27 16:51:03.000000000 -0700 @@ -80,6 +80,7 @@ thread_init (void) init_thread (initial_thread, "main", PRI_DEFAULT); initial_thread->status = THREAD_RUNNING; @@ -76,12 +76,12 @@ diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c /* Stack frame for kernel_thread(). */ kf = alloc_frame (t, sizeof *kf); -@@ -224,16 +226,33 @@ thread_tid (void) +@@ -224,16 +226,34 @@ thread_tid (void) void thread_exit (void) { + struct thread *t = thread_current (); -+ list_elem *e; ++ list_elem *e, *next; + ASSERT (!intr_context ()); @@ -93,10 +93,11 @@ diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c + latch_release (&t->ready_to_die); + + /* Notify our children that they can die. */ -+ for (e = list_begin (&t->children); e != list_end (&t->children); -+ e = list_next (e)) ++ for (e = list_begin (&t->children); e != list_end (&t->children); e = next) + { + struct thread *child = list_entry (e, struct thread, children_elem); ++ next = list_next (e); ++ list_remove (e); + sema_up (&child->can_die); + } + @@ -111,13 +112,12 @@ diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c schedule (); NOT_REACHED (); } -@@ -270,6 +290,22 @@ thread_block (void) - thread_current ()->status = THREAD_BLOCKED; - schedule (); - } -+ -+/* Waits for thread with tid CHILD_TID to die. */ -+void +@@ -283,8 +290,18 @@ thread_block (void) + This function will be implemented in problem 1-2. For now, it + does nothing. */ + void +-thread_join (tid_t child_tid UNUSED) +-{ +thread_join (tid_t child_tid) +{ + struct thread *cur = thread_current (); @@ -130,10 +130,9 @@ diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c + if (child->tid == child_tid) + latch_acquire (&child->ready_to_die); + } -+} - - /* Idle thread. Executes when no other thread is ready to run. */ - static void + } + + /* Sets the current thread's priority to NEW_PRIORITY. */ @@ -335,6 +371,9 @@ init_thread (struct thread *t, const cha strlcpy (t->name, name, sizeof t->name); t->stack = (uint8_t *) t + PGSIZE; @@ -144,9 +143,9 @@ diff -X pat -urpN pintos.orig/src/threads/thread.c pintos/src/threads/thread.c t->magic = THREAD_MAGIC; } -diff -X pat -urpN pintos.orig/src/threads/thread.h pintos/src/threads/thread.h ---- pintos.orig/src/threads/thread.h 2004-09-26 14:15:17.000000000 -0700 -+++ pintos/src/threads/thread.h 2004-09-27 16:50:14.000000000 -0700 +diff -X pat -urpN src/threads/thread.h~ src/threads/thread.h +--- src/threads/thread.h~ 2004-09-26 14:15:17.000000000 -0700 ++++ src/threads/thread.h 2004-09-27 16:50:14.000000000 -0700 @@ -4,6 +4,7 @@ #include #include