MAINSAIL Language Manual, Section 43.2

previous   next   top   complete contents   complete index   framed top   this page unframed


43.2. $okToMixCoroutinesAndForeignCalls

Temporary feature: subject to change

Figure 43–2. $okToMixCoroutinesAndForeignCalls
BOOLEAN
<
macro>     $okToMixCoroutinesAndForeignCalls;

On some systems, the flow of control gets tangled if a program mixes coroutines and calls to foreign code in the following way:

This can work only on systems that use a separate stack for each coroutine's foreign calls. On some systems, all foreign calls use the same separate foreign stack, regardless of the MAINSAIL coroutine from which the call was made. This means that when control returns from MAINSAIL to a foreign procedure, the foreign procedure must be the most recently invoked foreign procedure that is still active. If another foreign procedure was called since then in a different coroutine and that procedure is still active, then the return from MAINSAIL to the first foreign procedure would get tangled.

This limitation is currently present only on platforms based on the SPARC processor (SOLRS, PSOLRS, and SUN4). On these systems, it would be quite difficult to lift the limitation. It is also possible (although unlikely) that some future platform would suffer from the same limitation.

The macro $okToMixCoroutinesAndForeignCalls (a temporary feature) allows a program to determine whether entry FLI calls and coroutines can be safely mixed on the current platform.

If $okToMixCoroutinesAndForeignCalls returns TRUE, then on the current host, calls to foreign code use a separate stack for each coroutine, and thus calls between MAINSAIL and foreign code may be interspersed freely with coroutine switching.

A result of FALSE indicates that all calls to foreign code use the same stack, regardless of which MAINSAIL coroutine may have been current at the time the call was made. Thus, if two foreign calls (even those made from different coroutines) are ever active at the same time, the one that occurred later must exit first. Otherwise, the flow of control would get tangled.

$okToMixCoroutinesAndForeignCalls is currently TRUE on all platforms except SOLRS, PSOLRS, and SUN4.

The value of $okToMixCoroutinesAndForeignCalls for a given system is subject to change.


previous   next   top   complete contents   complete index   framed top   this page unframed

MAINSAIL Language Manual, Section 43.2