From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giuseppe Scrivano Newsgroups: gmane.emacs.devel Subject: Re: advice needed for multi-threading patch Date: Wed, 23 Sep 2009 20:43:38 +0200 Message-ID: <87zl8lwlgl.fsf@master.homenet> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253731518 2294 80.91.229.12 (23 Sep 2009 18:45:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Sep 2009 18:45:18 +0000 (UTC) Cc: Tom Tromey , Emacs development discussions To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 23 20:45:11 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MqWpy-00030U-UU for ged-emacs-devel@m.gmane.org; Wed, 23 Sep 2009 20:45:11 +0200 Original-Received: from localhost ([127.0.0.1]:48416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqWpy-0003GV-6K for ged-emacs-devel@m.gmane.org; Wed, 23 Sep 2009 14:45:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MqWpt-0003GN-CX for emacs-devel@gnu.org; Wed, 23 Sep 2009 14:45:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MqWpo-0003EW-Fc for emacs-devel@gnu.org; Wed, 23 Sep 2009 14:45:04 -0400 Original-Received: from [199.232.76.173] (port=38296 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MqWpo-0003ET-9z for emacs-devel@gnu.org; Wed, 23 Sep 2009 14:45:00 -0400 Original-Received: from averell.mail.tiscali.it ([213.205.33.55]:46733) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MqWpk-0005Gm-AK; Wed, 23 Sep 2009 14:44:56 -0400 Original-Received: from master.homenet (84.222.168.3) by averell.mail.tiscali.it (8.0.022) id 4AA780C80061081D; Wed, 23 Sep 2009 20:44:41 +0200 Original-Received: from gscrivano by master.homenet with local (Exim 4.69) (envelope-from ) id 1MqWoU-0005Lg-Io; Wed, 23 Sep 2009 20:43:38 +0200 In-Reply-To: (Stefan Monnier's message of "Tue, 22 Sep 2009 10:24:15 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115557 Archived-At: Hello, Stefan Monnier writes: >> Right now when a thread yields it does not release its buffer lock. > > I think it should, unless some of the buffer-local variables are > let-bound by the thread. I think actually this is one of the most important decision to take, it will have a direct influence on buffer-local variables semantic. In my opinion, it is better to have few constraints and allow switch as often as possible. As Tom said, I was experimenting with gnus and it made me quite optimistic; in fact these commands are completed successfully: (run-in-thread '(gnus) t) ;; with t the thread doesn't attempt to get ;; a lock on the buffer. (while (yield)) ;; yield returns nil when there are not other ;; threads -- simulate join. The nolock argument in run-in-thread is just a hack to get things working and see quickly some results. Acquiring always the lock when accessing the buffer is too restrictive IMHO as too often the buffer is already locked. Following your advice to don't allow a switch only when buffer-local variables are let-bound by the thread, how many times it happens than a thread let-bound these variables? Let's say on 100 times, how many times approximately do you think a switch will not be allowed and the calling thread blocked? Cheers, Giuseppe