Date: Tue, 18 Jun 2013 17:48:49 +0900 (JST) From: Kohji Okuno <okuno.kohji@jp.panasonic.com> To: freebsd-current@FreeBSD.org Cc: okuno.kohji@jp.panasonic.com Subject: Are pthread_setcancelstate() and pthread_setcanceltype() cancellation points? Message-ID: <20130618.174849.1772987860003116966.okuno.kohji@jp.panasonic.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130618.174849.1772987860003116966.okuno.kohji>