It seems like a good time to take a breather and look at what we have going on so far. 

 

First, we’ve started the runtime.  We’ve handed our IHostControl off to the runtime.  The runtime has called back to our IHostControl and gotten a couple of managers.  Those are our task manager and our synchronization manager.  Whenever the runtime needs to create a thread it’s called us back, and we’ve created a brand new thread.  Sure, we’ve converted it into fibers, but we’ve done no real fiber switching. 

 

Whenever the runtime needed a manual or auto event we’ve given it to it via the synchronization APIs.  When it needed to block on it, it called us, and we blocked on it via IHostAutoEvent or IHostManualEvent.  If another thread alerted the thread blocked on the event, the runtime called us via the IHostTask APIs, and we queued and APC to it. 

 

If the runtime needed to enter a critical section, it called us, and we blocked or allowed it to enter via the IHostCrst APIs. 

 

We’ve set up everything necessary to replace the CLR’s threading model, but for the most part we’ve merely delegated to the OS APIs.  Sure, there were minor differences here and there…  But for every task the CLR asks for we create 1 physical thread.  And sure every one of those physical threads has already been converted to a fiber, but we never switch those fibers out. 

 

Starting with the next article that’ll start to change.