From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7515 Path: news.gmane.org!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: Resuming work on new semaphore Date: Fri, 24 Apr 2015 13:23:27 +0300 (MSK) Message-ID: References: <20150405190214.GF6817@brightrain.aerifal.cx> <20150405202314.GG6817@brightrain.aerifal.cx> <20150423160624.GF17573@brightrain.aerifal.cx> <20150424024638.GO17573@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 1429871028 11632 80.91.229.3 (24 Apr 2015 10:23:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Apr 2015 10:23:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7528-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 24 12:23:46 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Ylalq-0005g2-3J for gllmg-musl@m.gmane.org; Fri, 24 Apr 2015 12:23:42 +0200 Original-Received: (qmail 1802 invoked by uid 550); 24 Apr 2015 10:23:39 -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 1784 invoked from network); 24 Apr 2015 10:23:39 -0000 In-Reply-To: <20150424024638.GO17573@brightrain.aerifal.cx> User-Agent: Alpine 2.11 (LNX 23 2013-08-11) Xref: news.gmane.org gmane.linux.lib.musl.general:7515 Archived-At: On Thu, 23 Apr 2015, Rich Felker wrote: > Perhaps this can be patched up by saturating sem_getvalue's result? In > the case where the overflow happens it's transient, right? I think > that means discounting the overflow would be valid. But I'll need to > think about it more... Hm, can't agree here. This whole line of discussion stems from attempt to align timedwait/trywait/getvalue behavior in light of dead waiters, which are indistinguishable from preempted waiters. If "it's transient" claim can be made, it also can be used as a reason not to modify getvalue to look at val[1]. > With that said, my inclination right now is that we should hold off on > trying to commit the new semaphore for this release cycle. I've been > aiming for this month and just about everything else is in order for > release, but the semaphore rabbit-hole keeps going deeper and I think > we need to work through this properly. I hope that's not too much of a > disappointment. Ack; thankfully I don't feel disappointment in this case, this discussion has been quite entertaining. When I proposed my modification I felt it was very intuitive. What I did not grasp back then is that the definition of a waiter is not solid. How do you interpret the following? 1. Semaphore initialized to 0. There's only one thread. 2. alarm(1) 3. sem_wait() ... (in SIGALRM handler) 4. sem_post() 5. sem_getvalue() May getvalue be 0 here? At step 4, can the thread possibly "be a waiter" on the semaphore? Thanks. Alexander