From owner-freebsd-threads@freebsd.org Mon Feb 15 17:35:38 2016 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A821AA9E9F for ; Mon, 15 Feb 2016 17:35:38 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 78690A67 for ; Mon, 15 Feb 2016 17:35:38 +0000 (UTC) (envelope-from martin@lispworks.com) Received: by mailman.ysv.freebsd.org (Postfix) id 779B1AA9E9D; Mon, 15 Feb 2016 17:35:38 +0000 (UTC) Delivered-To: threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77284AA9E9C; Mon, 15 Feb 2016 17:35:38 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from lwfs1-cam.cam.lispworks.com (mail.lispworks.com [46.17.166.21]) by mx1.freebsd.org (Postfix) with ESMTP id 1E261A66; Mon, 15 Feb 2016 17:35:37 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (higson.cam.lispworks.com [192.168.1.7]) by lwfs1-cam.cam.lispworks.com (8.14.9/8.14.9) with ESMTP id u1FHZXVA039524; Mon, 15 Feb 2016 17:35:33 GMT (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (localhost.localdomain [127.0.0.1]) by higson.cam.lispworks.com (8.14.4) id u1FHZXwV006194; Mon, 15 Feb 2016 17:35:33 GMT Received: (from martin@localhost) by higson.cam.lispworks.com (8.14.4/8.14.4/Submit) id u1FHZXKV006190; Mon, 15 Feb 2016 17:35:33 GMT Date: Mon, 15 Feb 2016 17:35:33 GMT Message-Id: <201602151735.u1FHZXKV006190@higson.cam.lispworks.com> From: Martin Simmons To: Konstantin Belousov CC: vangyzen@FreeBSD.org, threads@FreeBSD.org, arch@FreeBSD.org In-reply-to: <20160215144410.GT91220@kib.kiev.ua> (message from Konstantin Belousov on Mon, 15 Feb 2016 16:44:10 +0200) Subject: Re: libthr shared locks References: <20151223172528.GT3625@kib.kiev.ua> <56BE69B8.9020808@FreeBSD.org> <20160213143815.GB91220@kib.kiev.ua> <201602151417.u1FEHKwL003392@higson.cam.lispworks.com> <20160215144410.GT91220@kib.kiev.ua> X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2016 17:35:38 -0000 >>>>> On Mon, 15 Feb 2016 16:44:10 +0200, Konstantin Belousov said: > > On Mon, Feb 15, 2016 at 02:17:20PM +0000, Martin Simmons wrote: > > > > Also, a general question: why not use some flag in the barrier (and other > > objects) to indicate pshared, removing the need for __thr_pshared_offpage > > except in init? > > But where would I keep the object ? All that I have with the current > ABI is a single pointer, which de facto behaves like the flag which you > proposed. It is either real pointer or (if set to some specific value > impossible for a valid pointer) there is an offpage. I'm probably missing something, but I was thinking pthread_barrier_init would do something like if ( attr is PTHREAD_PROCESS_PRIVATE ) { bar = calloc(1, sizeof(struct pthread_barrier)); pshared = 0; } else { bar = __thr_pshared_offpage(barrier, 1); pshared = 1; } bar->psharedflag = pshared; *barrier = bar; Then pthread_barrier_destroy would use the psharedflag slot to decide how to free it and pthread_barrier_wait would need no changes.