Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the new STM feature in .NET 4.0 Beta?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the new STM feature of .NET 4.0 Beta. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Microsoft has released a separate new version of. NET 4. 0 Beta 1 that includes STM.NET, or Software Transactional Memory. Usually we use lock-based synchronization mechanism to control access to shared memory, and STM is an alternative to locks.

Microsoft defines STM.NET as:

Software Transactional Memory (STM.NET) is a mechanism that can efficiently isolate the shared state. Developers can mark a piece of code as an "atomic" transaction and "isolate" it from other transaction code running in parallel.

Memory transaction (Transactional memory) is considered as a promising technology in academic circles, and in the current tide of using multi-core hardware to improve program scalability, it is also mentioned repeatedly as a popular technology. Its purpose is to enable application sequence developers to make use of the concurrency function of STM to combine components developed by experts. Memory transactions make this simple and secure.

STM uses optimistic concurrency mechanism to control access to shared memory, which does not block threads until they can safely modify shared data, but records read and write operations in logs when threads access shared data. It then checks to see if another thread accesses the shared data at exactly the same time. If not, these changes will be committed and take effect; otherwise, the transaction will be cancelled and all changes will be undone.

STM.NET uses Atomic.Do () to mark a piece of code as a transaction:

Atomic.Do (() = > {})

STM, like the locking mechanism, can degrade system performance because it needs to maintain read and write logs and takes extra time to commit. Some people think that STM is easier to use than locks, so the advantage of ease of use is enough to offset the performance degradation. In a project called "is transaction programming really easy?" In the study, Christopher J. Rossbach, Owen S. Hofmann and Emmett Witchel from the University of Texas at Austin compared the learning and development process between STM and locks:

In general, memory transactions require more development time than simple locks, but less than detailed locks and conditional synchronization.

We found that in more complex cases, simple locks and transactions take less time than detailed locks. This reflects the original intention of the transaction to reduce the complexity of coding, debugging, and locking sequences when multiple locks are required.

The study concluded:

This proves that even though beginners may have difficulty understanding transactions, transaction programming is safer than high-performance locks. The subjective evaluation of the students shows that they think that the transaction memory is more difficult than the simple lock, but it is easier than the careful lock and condition synchronization. However, in the code written by students, the rate of synchronization errors shows dramatic results. For similar programming problems, it is easier to get the correct results with transactions than with locks.

System configuration requirements: Visual Studio 2008 Internet Explorer Installer 3.1 or above, Internet Explorer 5.01 or above. Currently, STM.NET only supports C #.

So much for sharing about the new STM features of .NET 4.0 Beta. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report