same time. Plus, keeping VM is a great way to stress-test your
filesystem implementation.
-Your submission should define @code{THREAD_JOIN_IMPLEMENTED} in
-@file{constants.h} (@pxref{Conditional Compilation}).
-
@menu
* File System New Code::
* File System Synchronization::
There are a few exceptions:
@itemize @bullet
-@item
-Problem 1-2, @func{thread_join}. Some other code expects
-@code{THREAD_JOIN_IMPLEMENTED} to be defined once you've implemented
-this function.
-
@item
Problem 1-4, the advanced scheduler. We must be able to turn this on
and off with a compile-time directive. You must use the macro name we
Be careful to program this function correctly. You will need its
functionality for project 2.
-Once you've implemented @func{thread_join}, define
-@code{THREAD_JOIN_IMPLEMENTED} in @file{constants.h}.
-@xref{Conditional Compilation}, for more information.
-
@node Problem 1-3 Priority Scheduling
@section Problem 1-3: Priority Scheduling
relevant parts below. If you are confident in your HW1 code, you can
build on top of it. However, if you wish you can start with a fresh
copy of the code and re-implement @func{thread_join}, which is the
-only part of project #1 required for this assignment. Your submission
-should define @code{THREAD_JOIN_IMPLEMENTED} in @file{constants.h}
-(@pxref{Conditional Compilation}).
+only part of project #1 required for this assignment.
Up to now, all of the code you have written for Pintos has been part
of the operating system kernel. This means, for example, that all the
You will continue to handle Pintos disks and file systems the same way
you did in the previous assignment (@pxref{Using the File System}).
-Your submission should define @code{THREAD_JOIN_IMPLEMENTED} in
-@file{constants.h} (@pxref{Conditional Compilation}).
-
@menu
* VM Design::
* Page Faults::
LOG => $stem, DIE => "applying patch $stem failed\n");
}
- # Install default pintos/src/constants.h.
+ # Install default pintos/src/constants.h (which is empty).
open (CONSTANTS, ">pintos/src/constants.h")
or die "constants.h: create: $!\n";
- print CONSTANTS "#define THREAD_JOIN_IMPLEMENTED 1\n";
close CONSTANTS;
}
/* Example definition. */
/*#define MACRONAME 1 */
-
-/* Uncomment if if you've implemented thread_join(). */
-/*#define THREAD_JOIN_IMPLEMENTED 1*/
static thread_func *funcs[] = {io_thread, cpu_thread, io_cpu_thread};
static const char *names[] = {"IO", "CPU", "IO & CPU"};
struct semaphore done[3];
- tid_t tids[3];
int i;
printf ("\n"
for (i = 0; i < 3; i++)
{
sema_init (&done[i], 0, names[i]);
- tids[i] = thread_create (names[i], PRI_DEFAULT, funcs[i], &done[i]);
+ thread_create (names[i], PRI_DEFAULT, funcs[i], &done[i]);
}
/* Wait for threads to finish. */
for (i = 0; i < 3; i++)
- {
-#ifdef THREAD_JOIN_IMPLEMENTED
- thread_join (tids[i]);
-#else
- sema_down (&done[i]);
-#endif
- }
+ sema_down (&done[i]);
printf ("Multilevel feedback queue scheduler test done.\n");
}
tid_t tid;
printf ("\nExecuting '%s':\n", initial_program);
tid = process_execute (initial_program);
-#ifdef THREAD_JOIN_IMPLEMENTED
if (tid != TID_ERROR)
thread_join (tid);
-#endif
}
#else
/* Run the compiled-in test function. */
schedule ();
intr_set_level (old_level);
}
+
+/* Waits for the thread with the specified TID to terminate. If
+ TID has already terminated or TID does not refer to an
+ immediate child of the current thread, returns immediately.
+
+ This function will be implemented in problem 1-2. For now, it
+ does nothing. */
+void
+thread_join (tid_t child_tid UNUSED)
+{
+}
+
+/* Sets the current thread's priority to NEW_PRIORITY. */
+void
+thread_set_priority (int new_priority)
+{
+ thread_current ()->priority = new_priority;
+}
+
+/* Returns the current thread's priority. */
+int
+thread_get_priority (void)
+{
+ return thread_current ()->priority;
+}
\f
/* Idle thread. Executes when no other thread is ready to run. */
static void
void thread_exit (void) NO_RETURN;
void thread_yield (void);
-/* This function will be implemented in problem 1-2. */
void thread_join (tid_t);
-/* These functions will be implemented in problem 1-3. */
void thread_set_priority (int);
int thread_get_priority (void);
$(prep-grading)
$(mk-sandbox)
$(apply-patch) ../solutions/p1-2.patch
- echo '#define THREAD_JOIN_IMPLEMENTED 1' > $@/pintos/src/constants.h
$(run-tests) null
$(clean)