HW5
Necessary files:
Some observations:
- The translated monitor declaration does not initialize
monitor m; it would probably be desirable to do this.
In general, I will be fairly lenient with respect to your
implementation as long as you can demonstrate functionality.
- the n in void mon_wait(monitor *m, condition *c, int n);
refers to the scheduling priority of the process. As mentioned
in the notes, "on the corresponding signal, delayed process
with lowest value of p is selected."
- a couple of test ideas: semaphores, mutual exclusion algorithms
using semaphores
it seems that the present implementation of contexts.c does
not preemptively task switch (ie. context_timeout()
is not called), meaning that you can't just throw
context_enable()'s around haphazardly. You can make
a weakly fair monitor implementation by judicious use of
context_switch(context_select()), however. I'm looking
into this.
- Actually, contexts.c does work as designed, and
context_timeout() will indeed be called after some
amount of time. I apologize if my previous comment caused any
hassles.
- If you would like to terminate concurrency, it might be useful
to utilize a (static) "dummy" process. In start_concurrency(),
set current_process = dummy_process (probably the only
place where you should explicitly assign something to current_process)
and call a context_switch(). This will initialize
dummy_process so that a future context_switch(dummy_process)
will return to the execution point right after the initial
context_switch() in start_concurrency().
- New version of contexts.c posted, as I think there was a
subtlety regarding context_enable() and context_disable()
in the original implementation that maybe wasn't an issue when
the code was first written (~1996).
Last modified: 20030517, 2:15pm