From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] qunlock Date: Thu, 24 Jun 2004 16:02:16 +0500 From: dvd@davidashen.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: ab853370-eacd-11e9-9e20-41e7f4b1d025 >> /* canqlock(b); */ >> qunlock(b); > > This is very weird for me. > Can't you rework your scheme to avoid such things? > Perhaps this code is suggesting that your locking > conventions may need more work. That's why I am asking. What exactly is weird? The code actually works in SPIN (as a model), and in Python (but I check locked() before unlocking). The purpose is to have multiple producers and consumers on an queue with exclusive access, with priority always given to consumers if there are waiting ones and the queue is not empty. The implementation of qlock/qunlock allows to unlock when not locked; I am asking whether it is by design or by a coincidence? David