From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5942 Path: news.gmane.org!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: sem_getvalue conformance considerations Date: Wed, 27 Aug 2014 23:06:14 +0400 (MSK) Message-ID: References: <20140827023338.GA21076@brightrain.aerifal.cx> <1409123141.4476.18.camel@eris.loria.fr> <20140827074310.GK12888@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: ger.gmane.org 1409166498 30725 80.91.229.3 (27 Aug 2014 19:08:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2014 19:08:18 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5949-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 27 21:08:12 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XMiZn-0000Ju-7s for gllmg-musl@plane.gmane.org; Wed, 27 Aug 2014 21:08:11 +0200 Original-Received: (qmail 20324 invoked by uid 550); 27 Aug 2014 19:08:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20288 invoked from network); 27 Aug 2014 19:08:01 -0000 In-Reply-To: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) Xref: news.gmane.org gmane.linux.lib.musl.general:5942 Archived-At: On IRC Rich noted that I've too conveniently elided cancellation, so here's how I think cancellation handler should look like: val = sem->val[0]; while (val < 0) { /* We believe we are a waiter that no sem_post has "seen". */ oldval = val; if ((val = a_cas(sem->val, val, val+1)) == oldval) return; } /* We are a waiter, and a non-negative val[0] indicates that one sem_post * noticed us. Consume the corresponding wake count increment. */ a_dec(sem->val+1); Alexander