[context review] Updated vote

Hi all, There is a lack of reviews so far and the review deadline is getting close; as I really, really would like to see a context switching library into boost in one way or another, I would like to change my vote from a negative to conditional acceptance. These are the conditions: - A C (or low level), light weight API is publicly exposed and documented - Context is made movable, without additional memory allocation for non legacy (i.e. ucontext) implementations. - The documentation is polished and expanded with a discussion on context switching and use cases. I do not think these points are particularly contentious as Oliver has already stated that at least the first two is in his TODO list and that he will make context movable. Of course I would like Oliver to address the other points raised by me and others reviewers. I also encourage Oliver to engage more in discussions with the reviewers; the mail threads just died off after a few replies and not all issues raised were discussed. -- gpd

Hello Giovanni, thank you for your review (and of course all others) - it really helps to get the lib shaped (I got very view responses before the review). I've started to modify the lib (you can take a look at git://gitorious.org/boost-dev/boost-dev.git, branch context-dev) in order to address the issues raised by the review. If I believe all issues are addressed we can start a mini-review (or I'll send you and the other reviews an eMail for checking the new variant for discussion). best regards, Oliver Am 28.03.2011 15:46, schrieb Giovanni Piero Deretta:
Hi all,
There is a lack of reviews so far and the review deadline is getting close; as I really, really would like to see a context switching library into boost in one way or another, I would like to change my vote from a negative to conditional acceptance. These are the conditions:
- A C (or low level), light weight API is publicly exposed and documented - Context is made movable, without additional memory allocation for non legacy (i.e. ucontext) implementations. - The documentation is polished and expanded with a discussion on context switching and use cases.
I do not think these points are particularly contentious as Oliver has already stated that at least the first two is in his TODO list and that he will make context movable.
Of course I would like Oliver to address the other points raised by me and others reviewers.
I also encourage Oliver to engage more in discussions with the reviewers; the mail threads just died off after a few replies and not all issues raised were discussed.

On Mon, Mar 28, 2011 at 3:14 PM, Oliver Kowalke <oliver.kowalke@gmx.de> wrote:
Hello Giovanni,
thank you for your review (and of course all others) - it really helps to get the lib shaped (I got very view responses before the review).
I've started to modify the lib (you can take a look at git://gitorious.org/boost-dev/boost-dev.git, branch context-dev) in order to address the issues raised by the review. If I believe all issues are addressed we can start a mini-review (or I'll send you and the other reviews an eMail for checking the new variant for discussion).
Re mail: yes please. I'm taking a look at the code and I see you are doing quite a bit of changes. I couple of initial comments: - remember that all extern "C" functions are not really in the boost::contexts::details namespace, so you should really add a unique prefix to them (boost_context_* for example) - To support stateful functors you are using std::function that imply a certain overhead. Why not use something like this: assuming you have a C like make_context(context_impl*, void (*f)(void *)), change your trampoline function to something like this: template<class T> struct jump { T& x; context_impl *src, *dest; }; template<typename T> void trampoline(void * parm) { jump<T> & jmp = *static_cast<jump*>(parm); T x = jmp.x; swap_context(jmp.src, jmp.dest); x(); } now in context constructor: template<class T> context(T f) { context_impl temp_context; jump<T> p (f, &m_context, &temp_context); make_context(my_context, &trampoline<T>, &p); swap_context(&temp_context, &m_context); // here be magic } T has now been copied in at the bottom of the stack controlled by m_context. This requires a context switch in the constructor to copy T immediately, but it will probably cost less than constructing an std::funciton. Note that if you control the context_impl implementation and the associated make/swap context, you do not really need to invoke the trampoline function to do the copy, but you can carefully set-up the stack as if it had been done. A similar trick can be used to save a dynamic allocation of context_impl (for the ucontext_ case) or to make it an opaque type. HTH, -- gpd

Message du 28/03/11 16:15 De : "Oliver Kowalke" A : boost@lists.boost.org Copie à : Objet : Re: [boost] [context review] Updated vote
Am 28.03.2011 15:46, schrieb Giovanni Piero Deretta:
Hi all,
There is a lack of reviews so far and the review deadline is getting close; as I really, really would like to see a context switching library into boost in one way or another, I would like to change my vote from a negative to conditional acceptance. These are the conditions:
- A C (or low level), light weight API is publicly exposed and documented - Context is made movable, without additional memory allocation for non legacy (i.e. ucontext) implementations. - The documentation is polished and expanded with a discussion on context switching and use cases.
I do not think these points are particularly contentious as Oliver has already stated that at least the first two is in his TODO list and that he will make context movable.
Of course I would like Oliver to address the other points raised by me and others reviewers.
I also encourage Oliver to engage more in discussions with the reviewers; the mail threads just died off after a few replies and not all issues raised were discussed.
Hello Giovanni,
thank you for your review (and of course all others) - it really helps to get the lib shaped (I got very view responses before the review).
I've started to modify the lib (you can take a look at git://gitorious.org/boost-dev/boost-dev.git, branch context-dev) in order to address the issues raised by the review. If I believe all issues are addressed we can start a mini-review (or I'll send you and the other reviews an eMail for checking the new variant for discussion).
best regards, Oliver
Hi Oliver, as suggested by Giovanni, could you comment more deeply some issues as interaction of stack release and unwinding. This seems to be a safety hole on the design and it will be great if after the review we reach a consensus on how to solve it. Please post here all the modification you want to apply to the library so people can make comments without been forced to see you private repository. Thanks, Vicente

Am 29.03.2011 08:09, schrieb Vicente BOTET:
Please post here all the modification you want to apply to the library so people can make comments without been forced to see you private repository.
modifications: done: - context moveable - context simple class/not a template - context doesn't manage the stack (done) -> user has to safe pair of context and stack - SSE2 control word preserved in i386 asm too - bool context::finished() const indicates if context finished (context is unwound) - function associated with context stored on top of the stack - thx do GIovanni - function pointer or function-object can be used with context todo: - re-factoring C-API: boost_fcontext_make(), boost_fcontext_jump() - test-app for UNIX signals + boost::context - support for stack-unwinding using DWARF facilities (eh_frame) -> investigation if possible regarding to stack unwinding: the user has the possibility to check if the function called by context has finished (stack was cleaned up). The user can decide what to do - throw stack away, do some sophisticated work (jump back into stack and throw exception) or if possible and implementable use a unwind() function using DWARF facilities (eh_frame) to unwind the stack. Oliver
participants (3)
-
Giovanni Piero Deretta
-
Oliver Kowalke
-
Vicente BOTET