OpenTransport on OS X: Behavior of asynchronous API calls.
OpenTransport on OS X: Behavior of asynchronous API calls.
- Subject: OpenTransport on OS X: Behavior of asynchronous API calls.
- From: Matt Scopp <email@hidden>
- Date: Mon, 4 Nov 2002 18:17:02 -0800
Hello all. For those of you using the Open Transport APIs in the
Carbon environment on OS X, I wanted to mention an unexpected behavior
that you may encounter and how you can deal with it. The Carbon
implementation of Open Transport uses multiple worker threads in order
to emulate asynchronous API calls. This introduces a possibility that
hasn't existed on previous OT implementations: When making an API call
on an asynchronous provider, it's actually possible for the results of
the call to arrive and be delivered to your notifier before the call
itself returns.
One specific example of unwanted behavior that we have seen involves
so-called "missing T_GODATA events" on asynchronous endpoints that have
been flow-controlled. Analysis revealed that what actually happened in
that case was that the application called OTSnd on one thread, the send
was flow-controlled, but the flow control lifted very quickly and a
different thread (one of OT's worker threads) called the application's
notifier with a T_GODATA event before OTSnd ever returned kOTFlowErr to
the calling code.
The OTEnterNotifier and OTLeaveNotifier functions can be used to
prevent this from happening. Calling OTEnterNotifier on a provider
disables notifications on that provider until OTLeaveNotifier is called
on it. These calls can therefore be used to bracket critical sections
of code that require exclusion from a notifier executing concurrently,
like the OTSnd in the above example.
- Matt
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.