Cooperative Fiber Mode Sample – Day 11

Last week we went over the Abort and RudeAbort APIs.  This week we’ll go over Fiber.Exit.  This API provides a way for you to terminate a running fiber, and demonstrates a use of the unmanaged ICLRTask::ExitTask API.   The ExitTask API can only be called on a fiber that is currently switched in which gives us…

0

Cooperative Fiber Mode Sample – Day 10

In this article we’re going to look at the implementation of Abort and RudeAbort.  In the last article I mentioned that a typical host wouldn’t need to expose these to managed code.  Why is that?  If you have a fiber mode scheduler typically Thread.Abort will be sufficient.  Your scheduler will eventually schedule the task, and…

0

Cooperative Fiber Mode Sample – Day 9

The managed Fiber class exists in its own directory in the SDK sample appropriately called Fiber.  The Fiber class is designed to be vaguely similar to the managed Thread class.  For example, like the Thread has ThreadState the fiber has FiberStates.   The managed fiber class exposes a few significant APIs: ·        public static Fiber…

4

Cooperative Fiber Mode Sample – Day 8

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…

0

Cooperative Fiber Mode Sample – Day 7

At this point we’ve covered nearly all the major components of the unmanaged host.  The one remaining detail is the interface that’s used between the managed fiber mode implementation and the unmanaged host.  This is all implemented in callbacks.cpp.  We essentially expose an API for all the major operations we allow the fiber API to…

0

Cooperative Fiber Mode Sample – Day 6

The synchronization primitives are handled off to the runtime by the IHostSyncManager interface.  We’ve already provided this to the runtime through our GetHostManager callback on IHostControl.  Our IHostSyncManager is implemented on our IHostTaskManager and for the most part we just create objects and hand them off.  For example CreateCrst looks like:         *ppCrst =…

0

Cooperative Fiber Mode Sample – Day 5

Last time we successfully created a task and started it running.  That’s an accomplishment, but there are a couple of details we should get out of the way before we start to dive deeper into the fiber mode implementation.  Those are all on IHostTask and are Alert and Join.  Once again everything else is trivial…

1

Cooperative Fiber Mode Sample – Day 4

Last time we left off with the CLR calling into the host to create a task.  So far everything’s been very simple.  For each interface we’ve only needed to implement a couple of methods to get the bulk of the work done.  While I’ve certainly left out a couple of lines of code here and…

0

Cooperative Fiber Mode Sample – Day 3

When I last left off we went over the host control.  The host control hands off our task and synchronization managers.  Now it’s time to take a look at the two host-implemented managers, starting with the task manager.   I’m going to skip over the minor details such as constructors, destructors, etc… and only focus…

0

Cooperative Fiber Mode Sample – Day 2

In the last blog entry I went over how we start the runtime.  Once it was loaded we were running managed code, but I glossed over the managers that were present and participating in running the system.  Today we start off with CHostControl::GetHostManager.  CHostControl is CoopFiber’s implementation of IHostControl, and GetHostManager is the only API…

1