background preloader

Concurrency

Facebook Twitter

Parallel

MiniGuide: Parallel programming in .NET. The release of Microsoft's Parallel Extension for .NET 3.5 opens the door to the world of parallel programming for .NET developers. These extensions will help hide many of the messy details associated with running multiple threads from a single application, and can help simplify the development of applications that seamlessly scale from a single PC with multiple cores to grid computers composed of many servers with hundreds or even thousands of processing cores. This Mini Guide is a starting point for finding information on the parallel paradigm shift. When you register, you'll begin receiving targeted emails from my team of award-winning writers.

Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform. Concurrent Programming - A Primer : Marc Clifton explains some of the basic concepts of Parallel programming for .NET. Memory Models: Understand the Impact of Low-Lock Techniques in M. Practical Concurrency Patterns: Read-Write Cache - All Your Base. Assume that you have a set of worker threads producing and consuming information. In the process, there’s some generated data that can be cached instead of being calculated every time it is accessed. A typical solution for this problem is a thread-safe read-write cache (e.g. a .NET Dictionary) that will contain the calculated data.

Due to its changing nature, a lock must be taken when reading from the cache and when writing to the cache. This is typically a reader-writer lock, unless the data is changing very frequently. The following is a straightforward sketch of an implementation: public class ReadWriteCache<TKey, TValue> private Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); private ReaderWriterLockSlim _rwl = new ReaderWriterLockSlim(); public TValue Get(TKey key) //Throw if not found: _rwl.EnterReadLock(); try return _dict[key]; finally _rwl.ExitReadLock(); public TValue GetOrCreate(TKey key, Func<TKey, TValue> creator) //Start with a read lock to optimize TValue oldVal; Retlang - Google Code. Joe Duffy&#039;s Weblog. Algorithms for the masses - julian m bucknall. Back in November 2005, I wrote a series of articles on writing lock-free data structures in C# and illustrated the concepts with a lock-free stack, queue, limited-priority queue, and a free list.

All seemed well, except several people have commented that I never uploaded the source code and please could they have it? Why didn't I acquiesce? Well, ladies and gentlemen, there was a bug in the code. A really horrible bug. Awful: if you used the free list, the queue would blow up, rather nastily. So I spent some time at the end of last year trying to work out what was up. It was, gentle readers, to put it mildly, ugly. Eventually I just put it all away and hoped no one was reading the articles. Until today. Essentially, I'd forgotten to null out the Next field in FreeList.GetNode(). Anyway, without further ado, here's a bunch of links for you to tie all this up. Have fun! Home (CSP.NET)