From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xin Wang Newsgroups: gmane.lisp.guile.user Subject: Re: The equivalent of racket's break-thread in guile? Date: Fri, 31 May 2013 16:44:58 +0800 Message-ID: References: <1369972797.2610.57.camel@Renee-desktop.suse> <1369983337.2610.64.camel@Renee-desktop.suse> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0115f91c44001504ddffa171 X-Trace: ger.gmane.org 1369989917 8637 80.91.229.3 (31 May 2013 08:45:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 May 2013 08:45:17 +0000 (UTC) Cc: guile-user@gnu.org To: Nala Ginrut Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri May 31 10:45:16 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UiKxV-0001tt-0E for guile-user@m.gmane.org; Fri, 31 May 2013 10:45:13 +0200 Original-Received: from localhost ([::1]:53462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiKxU-0006mc-KL for guile-user@m.gmane.org; Fri, 31 May 2013 04:45:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiKxK-0006jo-IB for guile-user@gnu.org; Fri, 31 May 2013 04:45:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiKxH-0004MR-Eb for guile-user@gnu.org; Fri, 31 May 2013 04:45:02 -0400 Original-Received: from mail-vb0-x235.google.com ([2607:f8b0:400c:c02::235]:58982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiKxH-0004MN-9Z for guile-user@gnu.org; Fri, 31 May 2013 04:44:59 -0400 Original-Received: by mail-vb0-f53.google.com with SMTP id p13so842071vbe.26 for ; Fri, 31 May 2013 01:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5k4mp9+jqsxJut7z6xJm3LBahGzpguYD0k6it7HtVF4=; b=gzoJD9vB+93gFLxwKw1CuHegMLLcZMQmTzU9eGWUnVjxakyzIGujmPRCowqi13lrAb KN9Z5SIviN/C6R0cTU4iJXqm8q/m2eXHvs6SP/2iNuBgskgIMGjS+N6Hx4EA7HRZfSi+ Ba+3wPh54GgX8ADqfS2zydaNmwRFyvFP0fHIMVVPOVD32aeUot+0ZH1Tamk87E1U7ROJ /5tfDGhqkoqxdgg8Df64LVNXY0ilaT9BO0ahNR6ZVqTuGdBHbtwKrPeS0UyZ55QZ7DTW Y6gUhDcYCB34CmuMEXV/VBxAbAmgustbRwdGagN8bSFUoDL3Vvmx4HzpUPjBVTm+mvD3 9rIw== X-Received: by 10.220.191.129 with SMTP id dm1mr9267527vcb.54.1369989898827; Fri, 31 May 2013 01:44:58 -0700 (PDT) Original-Received: by 10.58.74.8 with HTTP; Fri, 31 May 2013 01:44:58 -0700 (PDT) In-Reply-To: <1369983337.2610.64.camel@Renee-desktop.suse> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c02::235 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10392 Archived-At: --089e0115f91c44001504ddffa171 Content-Type: text/plain; charset=ISO-8859-1 2013/5/31 Nala Ginrut > On Fri, 2013-05-31 at 14:24 +0800, Xin Wang wrote: > > > > > > > Thank you for pointing out this. > > > > > > After some more search, I found that pthread has function pthread_kill > > [1], which can be used to send signal to specific thread. > > > > > > No sure if it can be used to implement similar behaviour. > > > > > > [1] > > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html > > > At least in Linux, pthread_kill may effect the whole process: > ----------------------------cut---------------------------------- > Signal dispositions are process-wide: if a signal handler is > installed, the handler will be invoked in the thread thread, > but if the disposition of the signal is "stop", "continue", or > "terminate", this action will affect the whole process. > ----------------------------end---------------------------------- > > The real solution for your purpose is green-thread IMO. > > I see. But I think it is still doable, although not elegant. We can establish a signal handler to exit specific thread instead of a global terminate disposition, and then in thread pthread_sigmask() can be used to block that signal temporarily, before calling out-guard part of dynamic-wind. Some sample C code: https://gist.github.com/dram/5683646 > > > > > > > Regards, > > > Xin Wang > > > > > > > > > > > --089e0115f91c44001504ddffa171 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



2013/5/31 Nala Ginru= t <nalaginrut@gmail.com>
On Fri,= 2013-05-31 at 14:24 +0800, Xin Wang wrote:

>
>
> Thank you for pointing out this.
>
>
> After some more search, I found that pthread has function pthread_kill=
> [1], which can be used to send signal to specific thread.
>
>
> No sure if it can be used to implement similar behaviour.
>
>
> [1]
> http://pubs.opengroup.org/onlinepubs/96= 99919799/functions/pthread_kill.html


At least in Linux, pthread_kill may effect the whole process:
----------------------------cut----------------------------------
Signal =A0dispositions =A0are =A0process-wide: if a signal handler is
installed, the handler will be invoked in the thread thread,
but if the disposition of the signal is "stop", "continue&qu= ot;, or
"terminate", this action will affect the whole process.
----------------------------end----------------------------------

The real solution for your purpose is green-thread IMO.


I see.

But I think i= t is still doable, although not elegant.

We can establish= a signal handler to exit specific thread instead of a global terminate dis= position, and then in thread pthread_sigmask() can be used to block that si= gnal temporarily, before calling out-guard part of dynamic-wind.




>
>
> =A0 =A0 =A0 =A0 > Regards,
> =A0 =A0 =A0 =A0 > Xin Wang
>
>
>
>



--089e0115f91c44001504ddffa171--