Search

Tuesday, May 13, 2008

What is the similarity between Windows and Textile Industry

...they both use threads and fibers :)

Pink....

Most people are aware of processes and threads. Windows offers an even finer granularity over execution. This is called Fiber. To quote MSDN

A fiber is a unit of execution that must be manually scheduled by the application. Fibers run in the context of the threads that schedule them.

The obvious question that should come to managed code developers is whether .NET supports Fibers? The answer is from 2.0, CLR does support fiber mode. This means that there are hosting APIs using which a host can make CLR use Fibers to run its threads. So in effect there's no requirement that a .NET thread be tied to the underlying OS's threads. A classic example is that of SQL Server which hosts .NET in fiber mode because it wants to take care of scheduling directly. Head over to here (scroll down to SQL Server section) for an excellent read about this topic.

There's also the book Customizing the Microsoft .NET Framework Common Language Runtime written by Steven Pratschner which has a chapter on customizing CLR to use Fibers. I have already ordered the book. Once it comes in and I get a chance to read it, I'll post more about this.

2 comments:

Anonymous said...

More info about fiber and CLR from Joe Duffy's blog...

Fibers and the CLR: http://www.bluebytesoftware.com/blog/PermaLink,guid,2d0038b5-7ba5-421f-860b-d9282a1211d3.aspx

Abhinaba Basu said...

Actually I didn't link to it in purpose. I read that couple of years back and even though forgot the contents, the residual information made me argue with someone that we do not support managed threads on Fibers. Then I read up and figured out that, that was old information. SQLCLR runs fine on Fibers now...