From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:35179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqn6G-0006ax-MJ for qemu-devel@nongnu.org; Fri, 27 Jan 2012 09:48:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rqn6A-0007yH-H9 for qemu-devel@nongnu.org; Fri, 27 Jan 2012 09:48:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqn6A-0007y6-AV for qemu-devel@nongnu.org; Fri, 27 Jan 2012 09:48:18 -0500 Date: Fri, 27 Jan 2012 14:48:11 +0000 From: "Daniel P. Berrange" Message-ID: <20120127144811.GK6522@redhat.com> References: <4F22B71A.3020805@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4F22B71A.3020805@redhat.com> Subject: Re: [Qemu-devel] Coroutines and ucontext Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: abarcelo@ac.upc.edu, qemu-devel On Fri, Jan 27, 2012 at 03:39:22PM +0100, Paolo Bonzini wrote: > On 01/27/2012 01:39 PM, Alex Barcelo wrote: > >I have read that one of the reasons for using makecontext is that it > >saves the signal state. But there also exist functions like > >"sigsetjmp" and "siglongjmp" which can be used to jump around the > >coroutines while preserving signal masks. > > > >I have a patch that uses sigsetjmp and siglongjmp instead of > >makecontext and getcontext (and all the ucontext stuff), and it > >*seems* to work... but I'm not sure if it works "by accident" (not > >sure what I'm doing to the stack, not sure what I should be doing to > >the stack). > > You can post it, don't worry. I'm curious how you are switching > stacks when creating the coroutine. If you're curious about this kind of thing you might also want to take a look at the GNU Pth code. In particular its pth_mctx.c file which has several different implementations of userspace thread switching, one using makecontext, another with sigstck/altstack and some others doing something fugly I don't understand :-) Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|