Princeton University |
Computer Science 510 |
|
More Final Exam Clarifications (Jan 11th)
Problem 2. Yesterday's "clarification" was not very useful. Let me just say that you are to implement mutex locks (without condition variables), and that if thread A attempts a withLock on a lock that is held by thread B, then thread A blocks (without busy waiting) and allows other threads to run until some later time when the lock is released.
Problem 3. Ignore yesterday's "clarification" and use the following specification instead.
After each interface operation (mkVar,mkExp,combine, or output), allow all f function evaluations to complete before accepting the next interface operation. You may assume that the f functions do not call the interface operations (which, of course, would lead to deadlock).
After each interface operation, each f function will execute at most once, because at most one variable has been assigned a new value.
It's all right if you have a central bottleneck. Here we are assuming that the slow thing is the evaluation of each individual f function (so they should be done in different threads), and we are not worrying about the time taken to synchronize between threads (within reason, of course).
Also, in the exam I wrote, "The function f passed to combine and update may be time-consuming to execute..." What I meant was, "The function f passed to combine and output may be time-consuming to execute..."
Final Exam Clarifications
assign(v, 2); assign(v, 5); output(mkExp(v), fn n=>print(Int.toString n))In a purely sequential implementation, such as the structure Pem given in the example, only the number 5 will be printed. In your concurrent implementation, it is all right if 2 is printed first, and eventually 5 will be printed. But 5 must the last number printed (by this particular instance of fn n=>print(Int.toString n)). To say this in another way, any particular output routine must eventually converge on the right answer.
Final Exam now available. I will answer questions in person and by e-mail until 2 p.m. on January 12. After that I will be away from my mail until after the due date of the exam.