Your SlideShare is downloading. ×
  • Like
  • Save
Non Blocking Algorithms at Traffic Conditions
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Non Blocking Algorithms at Traffic Conditions

  • 153 views
Published

Java Day 2013 Presentation …

Java Day 2013 Presentation
Presenter: Alina Ziyatova

Published in Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
153
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. www.ExigenServices.comNon-blocking algorithms at trafficconditionsAlina Ziyatova
  • 2. Your Reliable IT Business Solution ProviderHow to control shared resources?
  • 3. Your Reliable IT Business Solution ProviderRacesABvalue -> 7 7 + 1 -> 8 value = 8value -> 7 7 + 1 -> 8 value = 8
  • 4. Your Reliable IT Business Solution ProviderIncrement operationlong i = 0;i ++;readmodifyset
  • 5. Your Reliable IT Business Solution ProviderGuaranteed:Visibility of changesAtomicity of operationsDisadvantages:Throughputpublic synchronize void method() {// reading or modification}Modifier synchronize
  • 6. Your Reliable IT Business Solution ProviderThe worst caseDeadlockResource 1 Resource 2Thread 1 Thread 2I am waiting… I am waiting too…
  • 7. Your Reliable IT Business Solution ProviderAtomic packageAtomicLong i = new AtomicLong(0);i.getAndIncrement();readmodifyset
  • 8. Your Reliable IT Business Solution ProviderCompare & Set operationsRead the valueReturn falseIs it differ from expected one?ModifyReturn true
  • 9. Your Reliable IT Business Solution ProviderCompare & Set operationsRead a valueof thevariablePerform anintermediatecomputingRead a value of thevariable again andcompare withprevious oneHas the valuechanged?YesNo
  • 10. Your Reliable IT Business Solution ProviderNon-blocking algorithmsWait-freeNon-blockingLock-free
  • 11. Your Reliable IT Business Solution ProviderStackHEADLast In – First Out1 2null32 3
  • 12. Your Reliable IT Business Solution ProviderTreiber’s algorithm for StackNodestatic class Node<E> {final E item;Node<E> next;public Node(E item) {this.item = item;}}1 2
  • 13. Your Reliable IT Business Solution ProviderTreiber’s algorithm for Stackimport java.util.concurrent.atomic.AtomicReference;public class ConcurrentStack<E> {AtomicReference<Node<E>> head =new AtomicReference<Node<E>>();//. . .}HEAD1 2
  • 14. Your Reliable IT Business Solution ProviderTreiber’s algorithm for StackHEAD123Push a new NodeRead referenceUpdate next fieldCAS. . .1 22 310 10
  • 15. Your Reliable IT Business Solution ProviderTreiber’s algorithm for StackRemove a NodeHEAD13Read reference to next itemCAS. . .Read head reference222 3121
  • 16. Your Reliable IT Business Solution ProviderPerformance comparison02000000400000060000008000000100000001200000014000000160000001 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16ConcurrentHashMapConcurrentSkipListMapSynchronizedHashMapSynchronizedTreeMapHashtableNumber of threadsWin7 Enterprise, Intel Core i5-2500Add probability = 0.6, Remove probability = 0.1Java version 1.6.0_37
  • 17. Your Reliable IT Business Solution ProviderPerformance comparisonWin7 Enterprise, Intel Core i5-2500Add probability = 0.2, Remove probability = 0.605000000100000001500000020000000250000001 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16ConcurrentHashMapConcurrentSkipListMapSynchronizedHashMapSynchronizedTreeMapHashtableJava version 1.6.0_37Number of threads
  • 18. Your Reliable IT Business Solution ProviderConclusionChoose a type of Collectionsdepending on your taskNon-blocking algorithms mayconsume full resources of a server
  • 19. Your Reliable IT Business Solution ProviderPerformance comparisonWin7 Enterprise, Intel Core i5-2500Add probability = 0.6, Remove probability = 0.1050000001000000015000000200000002500000030000000350000001 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16Java 1.7.0Java 1.6.0_37ConcurrentHashMapNumber of threads
  • 20. Your Reliable IT Business Solution ProviderQuestions