CS 330 Home Schedule Resources

Study Guide 9
Covers portions of 4 - 4.5 Declarative Concurrency and Laziness

  1. Why doesn't adding a thread around any statement of a program change the result of that program in Oz? Would this be true for Java or C++? Why or why not? If it doesn't change the result, what is it good for?
  2. What is nondeterminism? What is observable nondeterminism? Does the model in Chater 4 have either of these properties?
  3. What does it mean for concurrency to be declarative?
  4. Is the following local statement declarative from the perspective of any code around it (ie. code in the "..." area)? Why or why not?
       declare JohnsLunch=pizza JanesLunch=hamburger Lunch in
       local L1 S1 in
         thread try L1=JohnsLunch=JanesLunch S1=ok
         catch _ then S1=error end end
         if S1==error then Lunch=sandwich
         else Lunch=L1 end
       end
       ...
    
  5. Which of the following are true statements about threads?
    1. Threads have priorities, and their priority level can be customized or changed over time.
    2. A thread can be in one of exactly three states: runnable, blocked, or terminated.
    3. Any thread A can force any other thread B to suspend, even without B's cooperation.
    4. A programmer can simulate coroutining using Mozart threads.
    5. A thread can tell its name to another thread if it wishes.
    6. Fairness in thread scheduling is necessary to maintain the modularity or declarativeness of a program.
  6. How can laziness be achieved in a language without the ByNeed primitive (or lazy keyword), ie., how can it be done manually?
  7. Match each of the computation models 1-6 with the appropriate description A-D of the stages possible in a variable's lifetime.
    1. eager, sequential execution with a value store
    2. eager, sequential execution with both a value store and data flow variables
    3. lazy sequential execution with a value store
    4. lazy sequential execution with a value store and dataflow variables
    5. concurrent eager execution with both a value store and dataflow variables
    6. concurrent sequential execution with both a value store and dataflow variables
  8. Why is fairness in thread scheduling necessary to maintain the modularity or declarativeness of a program?
  9. A __________ can occur in a sequential language with dataflow variables when the result of one lazy expression depends on a dataflow variable that gets initialized in another lazy expression, and the second expression becomes needed after the first.