.NET或Windows同步原语性能规范 [英] .NET or Windows Synchronization Primitives Performance Specifications

查看:87
本文介绍了.NET或Windows同步原语性能规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写一篇科学文章,我需要非常准确地引用。有人可能指向我的MSDN,MSDN文章,一些发表文章来源或一本书,我可以找到Windows或.NET同步原语的性能比较。

I am currently writing a scientific article, where I need to be very exact with citation. Can someone point me to either MSDN, MSDN article, some published article source or a book, where I can find performance comparison of Windows or .NET Synchronization primitives.

我知道这些是以降序的性能顺序:联锁的API,Critical Section,.NET锁定语句,Monitor,Mutex,EventWaitHandle,Semaphore。

I know that these are in the descending performance order: Interlocked API, Critical Section, .NET lock-statement, Monitor, Mutex, EventWaitHandle, Semaphore.


Ovanes

Many Thanks,
Ovanes

PS我找到了一本好书: Windows上的并发编程Joe Duffy 。这本书是由.NET Framework的头并发开发人员编写的,非常精彩,有很多解释,工作原理或实现方式。

P.S. I found a great book: Concurrent Programming on Windows by Joe Duffy. This book is written by one of the head concurrency developers for .NET Framework and is simply brilliant with lots of explanations, how things work or were implemented.

推荐答案

对于来自无锁编程注意事项对于Xbox 360和Microsoft Windows 可能会很方便。

For a rough comparison following numbers from Lockless Programming Considerations for Xbox 360 and Microsoft Windows may come handy.

Windows上的同步指令和功能因处理器类型和配置以及运行的其他代码而异。多核和多插槽系统通常需要更长的时间来执行同步指令,如果另一个线程当前拥有锁,则获取锁需要更长时间。

The performance of synchronization instructions and functions on Windows vary widely depending on the processor type and configuration, and on what other code is running. Multi-core and multi-socket systems often take longer to execute synchronizing instructions, and acquiring locks take much longer if another thread currently owns the lock.

但是,即使是通过非常简单的测试生成的一些测量也很有用:

However, even some measurements generated from very simple tests are helpful:


  • MemoryBarrier -90周期。

  • InterlockedIncrement 被测量为 36-90周期

  • 获取或发布关键区段的测量为 40-100个周期

  • 获取或发布 mutex 测量为大约 750-2500个周期

  • MemoryBarrier was measured as taking 20-90 cycles.
  • InterlockedIncrement was measured as taking 36-90 cycles.
  • Acquiring or releasing a critical section was measured as taking 40-100 cycles.
  • Acquiring or releasing a mutex was measured as taking about 750-2500 cycles.

在Windows XP上的一系列不同的处理器。短时间在单处理器机器上,而更长的时间在多处理器机器上。

These tests were done on Windows XP on a range of different processors. The short times were on a single-processor machine, and the longer times were on a multi-processor machine.

这篇关于.NET或Windows同步原语性能规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆