Development Cycles
  Home arrow Development Cycles arrow Page 3 - A Peek into the Future: Transactional Memo...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DEVELOPMENT CYCLES

A Peek into the Future: Transactional Memory
By: Mohamed Saad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-06-19

    Table of Contents:
  • A Peek into the Future: Transactional Memory
  • Previous synchronization mechanisms
  • Transactional memory
  • So why is it not being used everywhere now?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A Peek into the Future: Transactional Memory - Transactional memory


    (Page 3 of 4 )

    Transactional memory is believed to be the synchronization scheme of the future. First, it is much harder to get a deadlock with transactional memory (even though it is still possible), and second and most importantly, it doesn't suffer from the granularity problem described above. In other words, if two threads are accessing the same data structure, but are accessing different portions of it, the transactional memory scheme will let them proceed in parallel without any overhead. Intervention is needed only when two threads try to access the same portion of a data structure.

    How will the programs look?

    Transactional memory doesn't use locks or tokens or anything. It is based on the concept of a transaction. This can be described as an all-or-nothing approach. If your transaction can execute from beginning to end without conflicts, it will proceed and all the changes will be made. If any conflicts occur, it will roll back and all changes are cancelled.

    Remember that array copying example? Let's see how it would look.

      Subroutine Move(Array A, Array B)
       
    Atomic
       
    {
          Read X from Array A
         
    Write X to Array B
       
    }

    Very simple and neat, isn't it? What does this really do? Quite simply, it tells the compiler that you should try to read an element from array A and write it to array B. But, here is the catch, you should do this as one transaction. If at any time you detect any conflicts, roll back and assume that you have done nothing. For example, if you read from A without problems, and then detect a conflict while writing to B, you should abort the writing part, AND you should throw away the value X you read from A. This last part is very important, because some other thread could be trying to move an element into A. Since we have rolled back, we can no longer use the value we read from A. We should retry the whole transaction from the beginning. This way, we are always sure our data structures are consistent and having no conflicts.

    As you can see, transactional memory systems are based on an optimistic approach. They let all the threads execute and only roll back when a conflict is detected. As you might guess, in real life, conflicts don't occur all that often! So, typically a transactional memory system should be able to outperform other schemes. It is also much simpler than locks and monitors. Finally, as mentioned before, it is not easy to get a transactional memory scheme to deadlock.

    More Development Cycles Articles
    More By Mohamed Saad


       · Hello All, Mohamed here. I hope you enjoyed the article. Transactional memory is a...
       · Your deadlock example is wrong. The code, as written, will not deadlock in the...
       · i do think the code can end up in a deadlock...while you are correct in saying that...
     

    DEVELOPMENT CYCLES ARTICLES

    - Branch and Bound Algorithm Technique
    - Dynamic Programming Algorithm Technique
    - Genetic Algorithm Techniques
    - Greedy Strategy as an Algorithm Technique
    - Divide and Conquer Algorithm Technique
    - The Backtracking Algorithm Technique
    - More Pattern Matching Algorithms: B-M
    - Pattern Matching Algorithms Demystified: KMP
    - Coding Standards
    - A Peek into the Future: Transactional Memory
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - Learning About the Graph Construct using Gam...
    - How to Strike a Match
    - Entity Relationship Modeling






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT