Consider the execution of the Apply method in Figure 6.4 in the text. Give a possible implementation of the decide method.
Picture is from The Art Of Multiprocessor programming By Maurice Herlihy & Nir Shavit
Chapter 6 Universality of Consensus 1 public class LFUniversal 2 private Node [] head; private Node tail; 4 public Universal0 ( 3 5 tail new Node (); 6 tail.seq 1; 7 for (int i0;in; i++) 8 head [i] tail 10 public Response apply(Invoc invoc) ( 11 inti. Thread ID.get(); 12 Node prefer new Node(invoc); 13 while (prefer.seq==0){ 14 15 16 17 18 head[i] = after; 19 Node before Node.max (head); Node after before.decideNext.decide(prefer); before . next = after; after.seq = before.seq + 1; 20 SeqObject myObject new Seqobject (); 21 Node c 22 while (current !=prefer)( 23 myObject.apply(current.invoc); urrent tail.next; 24 25 26 27 28 current - current.next; return myObject.apply(current.invoc); Figure 6.4 The lockfree universal algorithm. respective nodes to the head of the log by running nt was appended to the log. The inputs to The winner can then proceed to compute its respon do il versing the log, follow col to agree which node are references to the threads' nodes, and the result i que winni . Itdoes so a local copy of the sequential object and traversing thi g Chapter 6 Universality of Consensus 1 public class LFUniversal 2 private Node [] head; private Node tail; 4 public Universal0 ( 3 5 tail new Node (); 6 tail.seq 1; 7 for (int i0;in; i++) 8 head [i] tail 10 public Response apply(Invoc invoc) ( 11 inti. Thread ID.get(); 12 Node prefer new Node(invoc); 13 while (prefer.seq==0){ 14 15 16 17 18 head[i] = after; 19 Node before Node.max (head); Node after before.decideNext.decide(prefer); before . next = after; after.seq = before.seq + 1; 20 SeqObject myObject new Seqobject (); 21 Node c 22 while (current !=prefer)( 23 myObject.apply(current.invoc); urrent tail.next; 24 25 26 27 28 current - current.next; return myObject.apply(current.invoc); Figure 6.4 The lockfree universal algorithm. respective nodes to the head of the log by running nt was appended to the log. The inputs to The winner can then proceed to compute its respon do il versing the log, follow col to agree which node are references to the threads' nodes, and the result i que winni . Itdoes so a local copy of the sequential object and traversing thi g