-Index: src/constants.h
-===================================================================
-RCS file: /afs/ir.stanford.edu/users/b/l/blp/private/cvs/pintos/src/constants.h,v
-retrieving revision 1.4
-diff -u -p -r1.4 constants.h
---- src/constants.h 19 Oct 2004 17:37:30 -0000 1.4
-+++ src/constants.h 1 Jan 2005 02:13:41 -0000
-@@ -8,4 +8,4 @@
- /*#define MACRONAME 1 */
-
- /* Uncomment if if you've implemented thread_join(). */
--/*#define THREAD_JOIN_IMPLEMENTED 1*/
-+#define THREAD_JOIN_IMPLEMENTED 1
Index: src/threads/synch.c
===================================================================
RCS file: /afs/ir.stanford.edu/users/b/l/blp/private/cvs/pintos/src/threads/synch.c,v
schedule ();
NOT_REACHED ();
}
-@@ -300,6 +323,26 @@ kernel_thread (thread_func *function, vo
- function (aux); /* Execute the thread function. */
- thread_exit (); /* If function() returns, kill the thread. */
- }
-+
-+/* Waits for thread with tid CHILD_TID to die. */
+@@ -283,8 +290,22 @@ 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)
+-{
+int
+thread_join (tid_t child_tid)
+{
+ if (child->tid == child_tid)
+ {
+ latch_acquire (&child->ready_to_die);
-+ return child->exit_code;
++ return child->exit_code;
+ }
+ }
+ return -1;
-+}
- \f
- /* Returns the running thread. */
- struct thread *
+ }
+
+ /* Sets the current thread's priority to NEW_PRIORITY. */
@@ -336,6 +379,12 @@ init_thread (struct thread *t, const cha
strlcpy (t->name, name, sizeof t->name);
t->stack = (uint8_t *) t + PGSIZE;
/* Owned by thread.c. */
@@ -120,7 +132,7 @@ void thread_exit (void) NO_RETURN;
+ void thread_exit (void) NO_RETURN;
void thread_yield (void);
- /* This function will be implemented in problem 1-2. */
-void thread_join (tid_t);
+int thread_join (tid_t);
- /* These functions will be implemented in problem 1-3. */
void thread_set_priority (int);
+ int thread_get_priority (void);
Index: src/userprog/exception.c
===================================================================
RCS file: /afs/ir.stanford.edu/users/b/l/blp/private/cvs/pintos/src/userprog/exception.c,v
/* Starts a new thread running a user program loaded from
FILENAME. The new thread may be scheduled before
-@@ -26,31 +36,31 @@ static bool load (const char *cmdline, v
+@@ -26,31 +36,32 @@ static bool load (const char *cmdline, v
tid_t
process_execute (const char *filename)
{
- char *filename = filename_;
+ struct exec_info *exec = exec_;
struct intr_frame if_;
-- bool success;
+ bool success;
/* Initialize interrupt frame and load executable. */
memset (&if_, 0, sizeof if_);
-
- /* If load failed, quit. */
- palloc_free_page (filename);
-- if (!success)
-+ exec->success = load (exec->filename, &if_.eip, &if_.esp);
++ success = exec->success = load (exec->filename, &if_.eip, &if_.esp);
+ sema_up (&exec->load_done);
-+ if (!exec->success)
+ if (!success)
thread_exit ();
/* Switch page tables. */