The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,514 other followers

TMonitor versus Critical sections revisited: when possible, use SRWL over TMonitor, then TCritical section

Posted by jpluimers on 2020/08/19

Via [WayBack] TMonitor vrs Critical sections revisited. Back then (https://www.delphitools.info/2013/06/06/tmonitor-vs-trtlcriticalsection/), it was found that critic… – Kiriakos Vlahos – Google+ as he re-did the measurements that DelphiTools did before Delphi XE5 came out:

Slim Reader/Writer Lock (SWRL) is even faster than TMonitor:

  • CriticalSection 0.035
  • TMonitor 0.019
  • SWRL 0.012

Of course if you have a speedy lock-free solution, that is always favourable, but few people know how to write lock free data structures or how to find the libraries (despite Julian Bucknall covering quite a few of them in Delphi back in the days).

Related:

–jeroen

4 Responses to “TMonitor versus Critical sections revisited: when possible, use SRWL over TMonitor, then TCritical section”

  1. The biggest problem with SRW lock is that it is not fair. In cases where you have lots of readers and a single writer, the writer may not have a chance to hold the lock because there is always one or more readers. The Critical section doesn’t help much either. The best option is indeed going lock free.

  2. Stefan Glienke said

    When possible, don’t use any locking at all ;)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: