[Gluster-devel] thread-safety and stack based design

Vikas Gorur vikas at zresearch.com
Thu Jan 15 06:32:12 UTC 2009


Corin,

I think you are referring to STACK_WIND/UNWIND when you say
"stack-based" design. The STACK_WIND/UNWIND macros in effect implement
a continuation-like mechanism in C.

The original reason we introduced this was to make file operations
asynchronous, in that we didn't have to wait for the reply to come
back from a server to issue another request.

Simulating our own stack over the normal C stack has given us many
other advantages. To take a concrete example, if the posix-locks
translator wishes to block a call, all it needs to do is save the
frame for the call and return (return in the C stack). When it needs
to unblock, it simply does a STACK_UNWIND on the saved frame.

Similarly the stack mechanism allows a great deal of control for
translators like unify and afr, where control flow branches, loops,
etc.

By having the stack mechanism we explicitly transfer control from one
translator to another, which gives us enormous flexibility.

Vikas
-- 
Engineer - Z Research
http://gluster.com/





More information about the Gluster-devel mailing list