From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <61d4bbe5c7dc2aec46ffb603ed219b88@quanstro.net> To: 9fans@9fans.net From: erik quanstrom Date: Mon, 14 Jul 2008 15:07:58 -0400 In-Reply-To: <071420081847.25641.487B9F36000AB7F2000064292200761064040196960E040E9F@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] channel_lock Topicbox-Message-UUID: e69bab96-ead3-11e9-9d60-3106f5b1d025 > I have been looking and the implementation of channels/alt in Plan9, > and I have a question. Does lock()/unlock() work across procs (not > just threads)? For example, in channel.c there is a static Lock > *channel_lock. Does this provide exclusive to channel data across > procs? > > I assume yes, just trying to make sure I'm understanding it > correctly. I was expecting to see code which handles channel access > "across procs" differently than channel access between threads "in > the same proc", but I didn't see anything like that. locks are not necessary between threads in the same proc because only one of them can run at a time and they are cooperatively scheduled. the only case that needs to be handled is locking between procs. thus there is no special case for locking between threads regardless of implementation on the other hand, if you look at the implementation of lock (/sys/src/libc/port/lock.c), it does not depend on the the implentation of threads or procs. it relies on an atomic tas instruction (or simuation thereof for mips) only. - erik