Answer to Homework 7

advertisement
Answer to Homework 7
Comparison of Java Monitor to Textbook Descriptions of Monitors
The maximum score was 10. Scores were determined by how many of the following
issues were mentioned. Mentioning most of these would have landed you a 10.







Of the two monitor constructs described in the textbook, the Java monitor is
closest to the Lampson/Redell model with the two extensions discussed for the
L/R model:
o cbroadcast to awake all waiting processes instead of just a specified one
o watchdog timer to awake awaiting processes after a certain amount of time
regardless of whether a signal was sent (to account for processes that may
have obtained the monitor but never signaled because they terminated
abnormally)
Every object and class in Java has the potential for becoming a monitor.
o methods that come with every class include wait and notify
o an object or class automatically becomes a monitor when the
“synchronized” reserved word is used properly in the object or class
the notify and wait of the Java monitor do not have a condition variable as a
parameter as does the L/R model
the wait data structures for entry to the L/R monitor and for the cwait calls inside
the L/R monitor are queues, whereas these are called sets in the Java monitor.
Thus, there is no presumption of a “first come first served” structure to the wait
data structures in Java. Entry and wait sets compete for entry when a process
signals.
Both monitor types use a signal and continue approach
Threads (processes) attempting to re-enter a monitor must recheck the condition
upon which they were waiting before proceeding in both monitors
Download