Hi Corin,<br><br>STACK_WIND and STACK_UNWIND are analogous to C procedure call and return from it. But, the major difference is that in C when a return is done from a procedure, the control is returned to the calling procedure, but when a STACK_UNWIND is done, the control is returned to the procedure provided as an argument to STACK_WIND macro (the &quot;cbk&quot; argument). The STACK_WIND macro stores the &quot;context&quot; (call back procedure etc) necessary to do this. A series of STACK_WIND macros results in a stack of these contexts built on heap and the corresponding STACK_UNWINDs results in unwinding of this stack (Note that the stack built due to calls to STACK_WIND is different from the C function stack, which is cleared as soon as the C function returns. But the &quot;context&quot;/stack built by STACK_WIND is preserved across C functions). <br>
<br>In other words, STACK_WIND/STACK_UNWIND implements continuations (provided by lisp and other languages) for glusterfs in C.<br><br>These two macros are among the basic building blocks of glusterfs&#39; asynchronous model of operation.<br>
<br>STACK_WIND/STACK_UNWIND pair of macros helps to handle the operations across the network (say between client and server) asynchronously. The request/reply for/to an operation is written to network, but the glusterfs is not blocked until the response is returned. Instead it &quot;pauses the current operation&quot; and continues to act upon requests for other operations. When the response is got, the corresponding &quot;paused operation&quot; is resumed using the stack built by series of STACK_WINDs till the request/reply was written to network.<br>
<br>regards,<br><br><div class="gmail_quote">On Thu, Oct 30, 2008 at 2:58 AM, Corin Langosch <span dir="ltr">&lt;<a href="mailto:corinl@gmx.de">corinl@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I just looked some time at the code but I think I just didn&#39;t get the<br>
usage of STACK_WIND / STACK_UNWIND right.<br>
<br>
Looking at the macros and the translators (for example), STACK_WIND<br>
simply seems to setup some datastructures and then call the suplied<br>
function. After that function is done, the MACRO is done and code<br>
executions continues normal.<br>
<br>
So if I put a STACK_WIND into a loop (like in unify) the function passed<br>
in the MACRO is simply called. So the calls don&#39;t happen in parallel but<br>
normal seriazliezd, as they would have happened without using<br>
STACK_WIND. So what is STACK_WIND all about - for me it currently seems<br>
to be for passing (some common) data between function calls. It doesn&#39;t<br>
execute any functions in parallel in order to reduce latencies caused by<br>
the backends?<br>
<br>
The function call in the STACK_UNWIND macro puzzles me even more. What<br>
is this for? As the STACK_UNWIND function is called from within the<br>
function called by STACK_WIND, I&#39;d suspect some kind of loop?<br>
<br>
What&#39;s about with the while(0) inside the macros. They don&#39;t do anything? ;)<br>
<br>
Thanks for any clarifications :)<br>
Corin<br>
<br>
<br>
_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a><br>
<a href="http://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">http://lists.nongnu.org/mailman/listinfo/gluster-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Raghavendra G<br><br>