From owner-freebsd-current@FreeBSD.ORG Tue Jun 18 09:15:58 2013 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E5E81E58 for ; Tue, 18 Jun 2013 09:15:58 +0000 (UTC) (envelope-from okuno.kohji@jp.panasonic.com) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by mx1.freebsd.org (Postfix) with ESMTP id 78913197B for ; Tue, 18 Jun 2013 09:15:58 +0000 (UTC) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile13) with ESMTP id r5I9FvSq016165 for ; Tue, 18 Jun 2013 18:15:57 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili17) with ESMTP id r5I9Fv312569 for ; Tue, 18 Jun 2013 18:15:57 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi16) id r5I9FvYR017113 for freebsd-current@FreeBSD.org; Tue, 18 Jun 2013 18:15:57 +0900 Received: from localhost by lomi16.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id r5I9FubM017086 for ; Tue, 18 Jun 2013 18:15:56 +0900 Date: Tue, 18 Jun 2013 18:15:56 +0900 (JST) Message-Id: <20130618.181556.452619654831646148.okuno.kohji@jp.panasonic.com> To: freebsd-current@FreeBSD.org Subject: Re: Are pthread_setcancelstate() and pthread_setcanceltype() cancellation points? From: Kohji Okuno In-Reply-To: <20130618.174849.1772987860003116966.okuno.kohji@jp.panasonic.com> References: <20130618.174849.1772987860003116966.okuno.kohji@jp.panasonic.com> Organization: Panasonic Corporation X-Mailer: Mew version 6.5 on Emacs 24.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jun 2013 09:15:59 -0000 Hi, This is newer document. http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_05_02 > Hi, > > I have a question. > > Are pthread_setcancelstate() and pthread_setcanceltype() cancellation > points? > > I refered to the following URL. > > http://pubs.opengroup.org/onlinepubs/7908799/xsh/threads.html > > This document shows that cancellation points in the pthread library > are only pthread_cond_timedwait(), pthread_cond_wait(), pthread_join() > and pthread_testcancel(). > > But, current implementation in FreeBSD is the following. > (Please take notice of "(*)" marks). > > Would you check this? > > > lib/libthr/thread/thr_cancel.c: > 77 int > 78 _pthread_setcancelstate(int state, int *oldstate) > 79 { > 80 struct pthread *curthread = _get_curthread(); > 81 int oldval; > 82 > 83 oldval = curthread->cancel_enable; > 84 switch (state) { > 85 case PTHREAD_CANCEL_DISABLE: > 86 curthread->cancel_enable = 0; > 87 break; > 88 case PTHREAD_CANCEL_ENABLE: > 89 curthread->cancel_enable = 1; > 90 (*) testcancel(curthread); > 91 break; > 92 default: > 93 return (EINVAL); > 94 } > 95 > 96 if (oldstate) { > 97 *oldstate = oldval ? PTHREAD_CANCEL_ENABLE : > 98 PTHREAD_CANCEL_DISABLE; > 99 } > 100 return (0); > 101 } > 102 > 103 int > 104 _pthread_setcanceltype(int type, int *oldtype) > 105 { > 106 struct pthread *curthread = _get_curthread(); > 107 int oldval; > 108 > 109 oldval = curthread->cancel_async; > 110 switch (type) { > 111 case PTHREAD_CANCEL_ASYNCHRONOUS: > 112 curthread->cancel_async = 1; > 113 (*) testcancel(curthread); > 114 break; > 115 case PTHREAD_CANCEL_DEFERRED: > 116 curthread->cancel_async = 0; > 117 break; > 118 default: > 119 return (EINVAL); > 120 } > 121 > 122 if (oldtype) { > 123 *oldtype = oldval ? PTHREAD_CANCEL_ASYNCHRONOUS : > 124 PTHREAD_CANCEL_DEFERRED; > 125 } > 126 return (0); > 127 } > > > Regards, > Kohji Okuno > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"