From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <8ccc8ba40708100916o5bdf7c3eof067224764c06fd0@mail.gmail.com> Date: Fri, 10 Aug 2007 18:16:40 +0200 From: "Francisco J Ballesteros" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] does qlock(2) block all threads on a proc? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Topicbox-Message-UUID: a4525376-ead2-11e9-9d60-3106f5b1d025 It's a queueing lock, but otherwise just a lock. Thus, you use it like lock(), that is qlock(&l); ...isolated access to your shared data... qunlock(&l); The difference wrt lock/unlock is that it does not spin. If the lock cannot be set, the thread is put to sleep in queue waiting for the lock. So, it's better to use qlock in general than it is to use lock. (IIRC, lock is used to protect the data structure of the QLock, that might give you more insight regarding the difference b/w qlock and lock). hth On 8/10/07, david jeannot wrote: > Hi, > > Does qlock block all threads on a same proc? > I read lock(2) and thread(2) but I am not sure yet. > > Merci beaucoup, david >