From owner-freebsd-current@FreeBSD.ORG Tue Jun 18 08:59:15 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 7D04A16C for ; Tue, 18 Jun 2013 08:59:15 +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 0EB58183A for ; Tue, 18 Jun 2013 08:59:14 +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-maile14) with ESMTP id r5I8mo2K002675 for ; Tue, 18 Jun 2013 17:48:50 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili14) with ESMTP id r5I8mp023274 for ; Tue, 18 Jun 2013 17:48:51 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi14) id r5I8mpsN005172; Tue, 18 Jun 2013 17:48:51 +0900 Received: from localhost by lomi14.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id r5I8motr005146; Tue, 18 Jun 2013 17:48:50 +0900 Date: Tue, 18 Jun 2013 17:48:49 +0900 (JST) Message-Id: <20130618.174849.1772987860003116966.okuno.kohji@jp.panasonic.com> To: freebsd-current@FreeBSD.org Subject: Are pthread_setcancelstate() and pthread_setcanceltype() cancellation points? From: Kohji Okuno 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 Cc: okuno.kohji@jp.panasonic.com 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 08:59:15 -0000 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