<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//en">

<!–Converted with LaTeX2HTML 2022 (Released January 1, 2022) –> <HTML lang="en"> <HEAD> <TITLE>Contents of The No-Return / Multiple-Return Approach</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0"> <META NAME="Generator" CONTENT="LaTeX2HTML v2022">

<LINK REL="STYLESHEET" HREF="MPTHD.css">

<LINK REL="next" HREF="node4_mn.html"> <LINK REL="previous" HREF="node2_mn.html"> <LINK REL="up" HREF="node2_mn.html"> <LINK REL="next" HREF="node4_mn.html"> </HEAD>

<BODY bgcolor="#ffffff" text="#000000" link="#9944EE" vlink="#0000ff" alink="#00ff00">

<H2><A ID="SECTION00021000000000000000"> The No-Return / Multiple-Return Approach</A> </H2>

<P> In this approach, we create two special functions for context switching. One function has the special property that it never returns, but restores a prior context. As a compliment, the other function has the special property that it can return multiple times by first saving the current context (see figure below) (C already provides a primitive form of these functions with the <I>longjmp</I> and <I>setjmp</I> commands respectively, which are tailored to the compiler just to save the current ``C'' state.) These functions provide a great flexibility at the cost of complexity. The notion of a function that never returns or a function which returns multiple times is a little strange and unconventional. And it is easy to ``screw up'' by doing such things as <I>longjmp</I>ing into an unsaved or expired context, or mixing up the different returns from <I>setjmp</I>. Some higher-level approach may be more appropriate...

<P>

<DIV class="CENTER"><A ID="44"></A> <TABLE> <CAPTION class="BOTTOM"><STRONG>Figure:</STRONG> Control Flow of the Two Approaches to Context Switching</CAPTION> <TR><TD><IMG STYLE="height: 314.00ex; " SRC="img1.png" ALT="

\begin{figure}\begin{verbatim}No-Return / Multiple-Return Switch Funct...
...vert \vert * \vert \vert
V V * V V
x 1 * y 1
*\end{verbatim}
\end{figure}
"></TD></TR> </TABLE> </DIV>

<P>

<HR>

</BODY> </HTML>