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 1,860 other subscribers

Archive for the ‘Multi-Threading / Concurrency’ Category

Threads are not the answer | CompuTruthing

Posted by jpluimers on 2019/07/17

Long read, but worth it: [WayBack] Threads are not the answer | CompuTruthing

We argue that the thread-oriented approach to concurrency is a bad approach. It has severe modifiability problems, but also performance problems. We should not think in terms of low level primitives.

It has great analogies between threading and cars on roads:

Software world Automotive world
thread road
work unit set of cars that pass over a road in a period of time
work unit dependencies cars need to go from one road to another
total execution time total time for all cars to reach the destination
lock/semaphore traffic lights / roundabout
too few work unit dependencies (highway) road network badly connected (sometimes this means long way to nearby locations)
too many work unit dependencies too many intersections or access points (too much time spent in these)
too many small threads (descheduled often) small roads
threads that are not descheduled from cores highways

Via

[WayBack] Kevlin Henney – Google+ 

Related videos under the fold (more at DevTube – Videos by @kevlinhenney)

–jeroen

Read the rest of this entry »

Posted in Development, Multi-Threading / Concurrency, Software Development | Leave a Comment »

The red zone, is why you want immutable constructs

Posted by jpluimers on 2019/05/23

Most code I come across is in the red zone, exactly depicting why you want immutable constructs. Immutable constructs will never end-up in the red zone.

Image: [WayBackWayback Machine.

The red zone is just one quadrant on the mutability/shareability diagram and getting outside that red zone quadrant is key.

With processor cores now becoming ubiquitous: you cannot get outside of the “Shard” half, so you have to get outside of the “Mutable” half.

Explaining the why and how, is part of a few presentations that Kevlin Henney gave:

Related YouTube videos are below.

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Development, Event, Multi-Threading / Concurrency, Software Development | Leave a Comment »

ILockable/TLockable/Lockable. Similar to IManaged in Spring4D, but provides a Locked interface.

Posted by jpluimers on 2019/04/10

Had to use this to start solving threading issues in a project I inherited a while ago in a temporary way before doing a huge refactoring. Will likely need it in the future as well: ILockable/TLockable/Lockable. Similar to IManaged in Spring4D, but provides a Locked interface..

ILockable/TLockable/Lockable. Similar to IManaged(now IShared) in Spring4D, but provides a Locked interface.

Note this is very inefficient, but can be practical as a shotgun approach to start solving the mess when you inherit a project that has the “I know, I’ll use threads!” approach in it.

Replace the resource typed TNeedsLock that needs protection with a ILockable<TNeedsLock>, then route all references via a call to the Locked()() call to it.

If you need a simpler approach, then use [WayBack] Interfaced monitor lock — Bitbucket by Stefan Glienke.

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Multi-Threading / Concurrency, Software Development | Leave a Comment »

Requirements to write multi threaded code

Posted by jpluimers on 2019/04/01

Steps:

  1. get gist.github.com – Developers must be this tall to write multi threaded code
  2. render to PNG/PDF/HTML
  3. print
  4. attach to wall

Via [WayBack] Kristian Köhntopp – Google+

Related:

Bernd Paysan’s:

The three most 2. common race
1. off-by-one software conditions
errors:
counting
core dumped (Segmentation fault in printf)

–jeroen

Read the rest of this entry »

Posted in Development, Fun, Multi-Threading / Concurrency, Software Development | Leave a Comment »

*Recursive Parallel For Loops*…

Posted by jpluimers on 2019/03/28

Interesting thread: [WayBack] Recursive Parallel For LoopsI have an algorithm which isn’t a sorting algorithm but conceptually works similar to the Quicksort algorithm… – Steve Maughan – Google+

TL;DR: when splitting recursive algorithms in parallel, ensure you have a way to hard limit the number of threads.

–jeroen

Posted in Development, Multi-Threading / Concurrency, Software Development | Leave a Comment »

What is thread safety anyway?

Posted by jpluimers on 2017/12/13

A nice article [Archive.is] What is thread safety anyway? with a kind reference to the Deadlock Empire translation from C# to Delphi that I made.

In any language, multi-threading is hard, so I really love the quote below:

[WayBack] Multithreading can be hard to do right. The most common point of failure is assuming some code is thread safe when it actually is not... – Dalija Prasnikar – Google+

It reminded me of an old one:

A programmer had a problem. He thought to himself, “I know, I’ll solve it with threads!”. has Now problems. two he

–jeroen

Posted in .NET, C#, Delphi, Development, Fun, Multi-Threading / Concurrency, Quotes, Software Development, T-Shirt quotes | Leave a Comment »

If you thought you could do multi-threading, then play “The Deadlock Empire” games

Posted by jpluimers on 2016/10/04

Slay dragons, learn concurrency! Play the cunning Scheduler, exploit flawed programs and defeat the armies of the Parallel Wizard.

Source: The Deadlock Empire

Via: Face the dragon. Learn the ropes of concurrent programming. – Lars Fosdal – Google+

Source code is available and focuses on C#; maybe one day I’ll make a Delphi version: deadlockempire/deadlockempire.github.io: The Deadlock Empire: Slay dragons, learn concurrency!

BTW: a great book (with nice illustrations at both github and kernel.org) is Source: Is Parallel Programming Hard, And, If So, What Can You Do About It? [WayBack]

–jeroen

Posted in .NET, C#, Delphi, Development, Multi-Threading / Concurrency, Software Development | Leave a Comment »