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 18:33:55 +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=047d7b3a8f68ea73e804de012616 X-Trace: ger.gmane.org 1369996454 13705 80.91.229.3 (31 May 2013 10:34:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 May 2013 10:34:14 +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 12:34: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 1UiMf1-0003Fi-Uq for guile-user@m.gmane.org; Fri, 31 May 2013 12:34:16 +0200 Original-Received: from localhost ([::1]:34362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiMf1-00049r-Ib for guile-user@m.gmane.org; Fri, 31 May 2013 06:34:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiMeo-000455-28 for guile-user@gnu.org; Fri, 31 May 2013 06:34:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiMei-0000Dl-QK for guile-user@gnu.org; Fri, 31 May 2013 06:34:01 -0400 Original-Received: from mail-ve0-x233.google.com ([2607:f8b0:400c:c01::233]:59052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiMei-0000Da-J4 for guile-user@gnu.org; Fri, 31 May 2013 06:33:56 -0400 Original-Received: by mail-ve0-f179.google.com with SMTP id d10so975809vea.24 for ; Fri, 31 May 2013 03:33:56 -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=dBDLY2xt2l5XmIrv4ogtEnXyt5qYLGOmb494P1WUyY0=; b=f/x5EntSt4X3r7hgh8eknaK0KkTCuEIMbhhSCGRxix4mn6KFPKpdYRY1W0JfjgA+A2 x2xKjR8ppSwa7eCnHN/0zO7tsOre4XFx8jJZ/5FEgqrwGJEuwmiQQUQ2bem8noAmgoQy 3G1ybIVxijOfIq0usybKPKhlSGKt5m7G8Lg3Crgv5EOf8Mgu3e2tRYEfttYApq+AE9dm SmQVFHgcrQjzjHKdqYhEjGhlJ8MuB2IVN1CsgmFc5WeB4KElCBLV70h4HGjPzp79JSfn ciqzxYwsWiRen446yXr9BGhv+wJsAgj3IMZ8YQGJ98sqKRPc48dUNwdqI8LT47tUFK38 stDA== X-Received: by 10.220.40.212 with SMTP id l20mr9547629vce.29.1369996436007; Fri, 31 May 2013 03:33:56 -0700 (PDT) Original-Received: by 10.58.74.8 with HTTP; Fri, 31 May 2013 03:33:55 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::233 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:10393 Archived-At: --047d7b3a8f68ea73e804de012616 Content-Type: text/plain; charset=ISO-8859-1 2013/5/31 Xin Wang > > > > 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 > > I think I have found a much simpler method. pthread_cancel request can be blocked by pthread_setcancelstate. See code for more info: https://gist.github.com/dram/5684164 > >> > >> > >> > > Regards, >> > > Xin Wang >> > >> > >> > >> > >> >> >> > --047d7b3a8f68ea73e804de012616 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



2013/5/31 Xin Wang <= span dir=3D"ltr"><dram.wang@gmail.com>



2013/5/31 Nala Ginrut <nalaginrut@gmail.com= >
On Fri, 2013-05-31 a= t 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.

B= ut I think it is still doable, although not elegant.

We c= an establish a signal handler to exit specific thread instead of a global t= erminate disposition, and then in thread pthread_sigmask() can be used to b= lock that signal temporarily, before calling out-guard part of dynamic-wind= .


I think= I have found a much simpler method.

pthread_cancel request can be blocked by pthread_setcancelst= ate.

See code for more info: https://gist.github.com/dram/5684164



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




--047d7b3a8f68ea73e804de012616--