CLR 4.0: Parallel Extensions and the CLR ThreadPool

It’s been a while since I’ve posted; for the past several months I’ve been working on deep changes in the CLR ThreadPool to support the Parallel Extensions to the .NET Framework. I hope to say a few things about the changes we’re making in the CLR to support this new programming model over the coming…

0

Windows I/O threads vs. managed I/O threads

A question recently came up on an internal discussion forum, which I’ll paraphrase:  The Windows QueueUserWorkItem API has an option to queue to an I/O thread.  Why doesn’t the managed ThreadPool.QueueUserWorkItem support this option? First, some background: In the Windows thread pool (the old one, not the new Vista thread pool), an “I/O thread” is…

2

When does it make sense to use Win32 Fibers?

This has been discussed fairly frequently on the Web.    Chris Brumme discusses this here: http://blogs.msdn.com/cbrumme/archive/2003/04/15/51351.aspx Raymond Chen discusses this here:  http://blogs.msdn.com/oldnewthing/archive/2004/12/31/344799.aspx.  There’s some discussion about the pros and cons of Fibers in SQL Server here: http://msdn.microsoft.com/en-us/library/aa175385.aspx   Those are just the first three relevant links from a simple search.  But still, the subject comes…

4

ThreadPool changes in .NET 3.5 SP1 Beta

.NET 3.5 SP1 (A.K.A. CLR 2.0 SP2) is now available as a Beta release. This beta release has the fix for the ThreadPool ramp-up issue discussed here and here.  It also has some other improvements to the ThreadPool’s thread creation algorithm that can dramatically improve performance in some situations. The “thread injection” algorithm in the ThreadPool…

1

ThreadPool bug in CLR 2.0 SP1

Shortly after the release of CLR 2.0 SP1 (a.k.a. Orcas or .NET 3.5), several customers noticed some very odd behavior in the ThreadPool.  The ThreadPool is supposed to create threads as fast as possible, up to the current setting for MinThreads – but it turns out that if you queue workitems very quickly (like in…

3

When should you call RegisteredWaitHandle.Unregister?

The managed ThreadPool provides a way to asynchronously wait for WaitHandles, via ThreadPool.RegisterWaitForSingleObject. This method returns a new instance of RegisteredWaitHandle, which has a single method: Unregister.  It’s obvious from the name that this will cancel a pending wait operation.  What’s not obvious is that even after a registered wait has completed, you should still…

0