1 / 21

Lecture 7

Lecture 7. Discuss midterm Scheduling. Alternative Directory Structure. See hw 1 and hw 2. This one more aligned with UNIX directory structure. Idea for implementing processing is the same: at least conceptually separate traversal from maximum computation. UNIX style directory structure. *.

ferris
Download Presentation

Lecture 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 7 Discuss midterm Scheduling

  2. Alternative Directory Structure • See hw 1 and hw 2. • This one more aligned with UNIX directory structure. • Idea for implementing processing is the same: at least conceptually separate traversal from maximum computation.

  3. UNIX style directory structure * Directory entries DirectoryEntry inode filename INode FileName Ident Block Size int i; Mode * mode blocks RegularFile

  4. Maximum RegularFile size * Directory entries DirectoryEntry inode filename INode FileName Ident Block Size int i; Mode * mode blocks RegularFile Traversal: from Directory to RegularFile

  5. Maximum RegularFile size: implementation structure Directory entries DirectoryEntry_List inode INode DirectoryEntry Vector * Size int i; Mode Object mode RegularFile

  6. Collecting Informationduring traversal • Java does not have call by reference like C++ or Pascal. • Use IntegerRef class instead: class IntegerRef { private int i_; IntegerRef(int i) { i = i_;} public int getValue() {return i_;} public void setValue(int n) {i_ = n;} }

  7. From IntegerRef to Visitor pattern • Using class IntegerRef is not optimal: The code for computing the maximum is mixed with the traversal code. • A better but more elaborate solution would be to apply the visitor design pattern: instead of an IntegerRef-object, we give a MaxVisitor-object to the traversal.

  8. MaxVisitor class MaxVisitor { private int max; int size; MaxVisitor() { max = 0;} public int get_result() {return max;} public void before(INode host) {size = host.get_size();} public void before(RegularFile host) {if (size > max) max=size;} } // this visitor takes care of transporting size // the traversal is: from Directory to RegularFile

  9. DJ • If you use a library like DJ you can easily program in this style. • DJ: www.ccs.neu.edu/research/demeter/DJ • To learn about software development technology in general and Demeter in particular, take the COM 3360 class in the fall of 2000. See my home page.

  10. Vector in Java 2 • Vector now implements ListInterface. Use following idiom to iterate through list: for (ListIterator I = this.listIterator(); I.hasNext();) { … I.next(); … } • Start using Collection framework as much as possible.

  11. Semaphores in Java:Compare with WaitingStack public final class CountingSemaphore { private int count_ = 0; public CountingSemaphore(int inC) { count_ = inC;} public void P() { // down -- pop while (count_ = 0) try {wait();} catch (InterruptedException ex) {} --count_;} public void V() { // up -- push ++count_; notifyAll(); } } From: Concurrent Programming in Java by Doug Lea

  12. Puzzle: what is this? 0 N1 N2 T1 N2 1 N1 T2 N1 C2 C1 N2 T1 T2 T1 T2 C1 T2 T1 C2

  13. State modeling: two-process mutual exclusion N: noncritical region T: trying region C: critical region 0 N1 N2 T1 N2 1 N1 T2 N1 C2 C1 N2 T1 T2 T1 T2 Note: it is important to have two (T1,T2) C1 T2 T1 C2

  14. State modeling: two-process mutual exclusion N: noncritical region T: trying region C: critical region 0 N1 N2 T1 N2 1 N1 T2 N1 C2 C1 N2 T1 T2 T1 T2 C1 T2 T1 C2 AF(C1) true in 1 EF(C1 and C2) false in 0

  15. Reasoning about concurrency • Abstract from code • Computation tree logic reasons about systems at this level • Uses model-checking techniques

  16. Symbolic Model Checking • Determine correctness of finite state systems. • Developed at Harvard and later at CMU by Clarke/Emerson/Sistla • Specifications are written as formulas in a propositional temporal logic. • Temporal logic: expressing ordering of events without introducing time explicitly

  17. Temporal Logic • A kind of modal logic. Origins in Aristotle and medieval logicians. Studied many modes of truth. • Modal logic includes propositional logic. Embellished with operators to achieve greater expressiveness. • A particular temporal logic: CTL (Computation Tree Logic)

  18. Computation Tree Logic • Used to express properties that will be verified • Computation trees are derived from the state transition graphs • State transition graphs unwound into an infinite tree rooted at initial state

  19. S0 a b S0 S1 S2 S2 a c b c S0 S1 S1 S1 S2 structure S0 computation tree for S0

  20. Computation Tree Logic • CTL formulas built from • atomic propositions, where each proposition corresponds to a variable in the model • Boolean connectives • Operators. Two parts • path quantifier (A, E) • temporal operator (F,G,X,U)

  21. Computation Tree Logic • Paths in tree represent all possible computations in model. • CTL formulas refer to the computation tree If the signal req is high then eventually ack will also be high

More Related