This preview shows page 1-2-3-22-23-24-44-45-46 out of 46 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Trace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext curTail newNode head tail 0 λTrace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext curTail newNode head tail 0 λ 1 λ 2 λTrace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext curTail newNode head tail 0 λ 1 λ 2 λTrace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext λ λ curTail newNode head tail 0 λ 1 λ 2 λTrace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext λ λ curTail newNode head tail 0 λ 1 λ 2 λTrace 1 public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext λ λ curTail newNode head tail 0 λ 1 λ 2 λTrace 1: T1 wins public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6 if (tailNext != null) { // Queue in int. state, advance tail 7 tail.compareAndSet(curTail, tailNext); 8 else { // In quiescent state, try inserting new node 9 if (curTail.next.compareAndSet(null, newNode)) { // Insertion succeeded, try advancing tail 10 tail.compareAndSet(curTail, newNode); // will fail if tail already moved 11 return true; } } } } } Var T1 T2 tailNext λ λ curTail newNode head tail 0 λ 1 λ 2 λTrace 1: After CAS public boolean put(E item) { 1 Node<E> newNode = new Node<E>(item, null); 2 while (true) { 3 Node<E> curTail = tail.get(); 4 Node<E> tailNext = curTail.next.get(); 5 if (curTail == tail.get()) {// did tail change? 6


View Full Document

UMD CMSC 433 - Trace 1

Documents in this Course
Trace 1

Trace 1

62 pages

Reflection

Reflection

137 pages

Testing

Testing

25 pages

Paradigms

Paradigms

10 pages

Testing

Testing

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Jini

Jini

4 pages

Final

Final

15 pages

Java RMI

Java RMI

13 pages

Testing

Testing

16 pages

Load more
Download Trace 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Trace 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Trace 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?