Add helpful comment.
[pintos-anon] / src / userprog / process.c
index bece1fe95cc990c2e8313bf8481ed0b1e7136f52..781cc5d3fc81c9b95a65ed47b6d589c15895c91f 100644 (file)
@@ -18,7 +18,7 @@
 #include "threads/thread.h"
 #include "threads/vaddr.h"
 
-static thread_func execute_thread NO_RETURN;
+static thread_func start_process NO_RETURN;
 static bool load (const char *cmdline, void (**eip) (void), void **esp);
 
 /* Starts a new thread running a user program loaded from
@@ -39,7 +39,7 @@ process_execute (const char *file_name)
   strlcpy (fn_copy, file_name, PGSIZE);
 
   /* Create a new thread to execute FILE_NAME. */
-  tid = thread_create (file_name, PRI_DEFAULT, execute_thread, fn_copy);
+  tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy);
   if (tid == TID_ERROR)
     palloc_free_page (fn_copy); 
   return tid;
@@ -48,7 +48,7 @@ process_execute (const char *file_name)
 /* A thread function that loads a user process and starts it
    running. */
 static void
-execute_thread (void *file_name_)
+start_process (void *file_name_)
 {
   char *file_name = file_name_;
   struct intr_frame if_;
@@ -72,7 +72,7 @@ execute_thread (void *file_name_)
      arguments on the stack in the form of a `struct intr_frame',
      we just point the stack pointer (%esp) to our stack frame
      and jump to it. */
-  asm ("movl %0, %%esp; jmp intr_exit" :: "g" (&if_));
+  asm volatile ("movl %0, %%esp; jmp intr_exit" : : "g" (&if_) : "memory");
   NOT_REACHED ();
 }
 
@@ -117,7 +117,8 @@ process_exit (void)
 }
 
 /* Sets up the CPU for running user code in the current
-   thread. */
+   thread.
+   This function is called on every context switch. */
 void
 process_activate (void)
 {