Re: swapcontext() around pthreads

2012-08-09 Thread YAMAMOTO Takashi
hi, > On Thu, Aug 09, 2012 at 08:44:05PM +0200, Emmanuel Dreyfus wrote: >> setjmp and longjmp are claim to not match the requirement because they >> do not allow different stacks for each execution context. > > But there is a strong correlation between thread and stack, you can not > switch one w

Re: swapcontext() around pthreads

2012-08-09 Thread Joerg Sonnenberger
On Fri, Aug 10, 2012 at 05:11:02AM +0200, Emmanuel Dreyfus wrote: > Joerg Sonnenberger wrote: > > > Is there a point? Our swapcontext is effectively a system call. > > If it wasn't, it is still quite expensive for a routine that supposedly > > only changes %rsp followed by a call, at least for a

Re: swapcontext() around pthreads

2012-08-09 Thread Emmanuel Dreyfus
Joerg Sonnenberger wrote: > Is there a point? Our swapcontext is effectively a system call. > If it wasn't, it is still quite expensive for a routine that supposedly > only changes %rsp followed by a call, at least for architectures that > don't use a register window algorithm. It does more tha

Re: swapcontext() around pthreads

2012-08-09 Thread Emmanuel Dreyfus
Thor Lancelot Simon wrote: > > Right, but the question is: can we mimick the Linux behavior? > Would you jump off a bridge if all your friends were doing it? I propose offering optionnally the Linux behavior, which helps porting Linux applications. glusterfs usage of swapcontext is not a detail,

Re: swapcontext() around pthreads

2012-08-09 Thread Joerg Sonnenberger
On Fri, Aug 10, 2012 at 03:00:34AM +0200, Emmanuel Dreyfus wrote: > David Holland wrote: > > > Probably that the entire operating environment of B is cloned and run > > in thread A, that is, that it's a magic implementation of threaded > > continuations. > > Right, but the question is: can we mi

Re: swapcontext() around pthreads

2012-08-09 Thread Thor Lancelot Simon
On Fri, Aug 10, 2012 at 03:00:34AM +0200, Emmanuel Dreyfus wrote: > David Holland wrote: > > > Probably that the entire operating environment of B is cloned and run > > in thread A, that is, that it's a magic implementation of threaded > > continuations. > > Right, but the question is: can we mi

Re: swapcontext() around pthreads

2012-08-09 Thread Emmanuel Dreyfus
David Holland wrote: > Probably that the entire operating environment of B is cloned and run > in thread A, that is, that it's a magic implementation of threaded > continuations. Right, but the question is: can we mimick the Linux behavior? -- Emmanuel Dreyfus http://hcpnet.free.fr/pubz m...@n

Re: swapcontext() around pthreads

2012-08-09 Thread David Holland
On Thu, Aug 09, 2012 at 08:47:51PM +0200, Martin Husemann wrote: > On Thu, Aug 09, 2012 at 08:44:05PM +0200, Emmanuel Dreyfus wrote: > > setjmp and longjmp are claim to not match the requirement because they > > do not allow different stacks for each execution context. > > But there is a stro

Re: swapcontext() around pthreads

2012-08-09 Thread Martin Husemann
On Thu, Aug 09, 2012 at 08:44:05PM +0200, Emmanuel Dreyfus wrote: > setjmp and longjmp are claim to not match the requirement because they > do not allow different stacks for each execution context. But there is a strong correlation between thread and stack, you can not switch one without the othe

Re: swapcontext() around pthreads

2012-08-09 Thread Emmanuel Dreyfus
Joerg Sonnenberger wrote: > It sounds a lot like you should be using setjmp/longjmp in first place. > swapcontext works exactly as advertised and e.g. the thread base is part > of the context. I play back and forth between tech-kern@netbsd.org and gluster-de...@nongnu.org: setjmp and longjmp a

Re: swapcontext() around pthreads

2012-08-09 Thread Joerg Sonnenberger
On Thu, Aug 09, 2012 at 04:13:43PM +, Emmanuel Dreyfus wrote: > I encountered a funny portability problem when working on glusterfs. > In its 3.3. branch, it makes heavy use of swapcontext() and pthreads > to get better performance. Unfortunately the code assumes a Linux > specific behavior : a

swapcontext() around pthreads

2012-08-09 Thread Emmanuel Dreyfus
Hi I encountered a funny portability problem when working on glusterfs. In its 3.3. branch, it makes heavy use of swapcontext() and pthreads to get better performance. Unfortunately the code assumes a Linux specific behavior : a thread calling swapcontext() should not affect other threads. Only t