From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chetan Pandya Newsgroups: gmane.emacs.devel Subject: Re: multi-threaded Emacs Date: Sun, 30 Nov 2008 16:10:53 -0800 (PST) Message-ID: <502092.7273.qm@web83204.mail.mud.yahoo.com> References: <87abbg7qvj.fsf@master.homenet> Reply-To: pandyacus@sbcglobal.net NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228090303 9347 80.91.229.12 (1 Dec 2008 00:11:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Dec 2008 00:11:43 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: Miles Bader , Giuseppe Scrivano Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 01 01:12:45 2008 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 1L6wP6-0000YB-17 for ged-emacs-devel@m.gmane.org; Mon, 01 Dec 2008 01:12:44 +0100 Original-Received: from localhost ([127.0.0.1]:51810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6wNv-0000OS-SE for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2008 19:11:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L6wNM-0008C9-Q0 for emacs-devel@gnu.org; Sun, 30 Nov 2008 19:10:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L6wNM-0008BV-16 for emacs-devel@gnu.org; Sun, 30 Nov 2008 19:10:56 -0500 Original-Received: from [199.232.76.173] (port=44849 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6wNL-0008BN-S5 for emacs-devel@gnu.org; Sun, 30 Nov 2008 19:10:55 -0500 Original-Received: from web83204.mail.mud.yahoo.com ([216.252.101.48]:29815) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1L6wNL-00007A-6a for emacs-devel@gnu.org; Sun, 30 Nov 2008 19:10:55 -0500 Original-Received: (qmail 8998 invoked by uid 60001); 1 Dec 2008 00:10:53 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=sbcglobal.net; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=3Bp3aw8wKkMRLuWB9PkxSkjJjfBuJYp7A6r8YxnQnTY5tFusxF17BfDZ76Sqs74rLWsBaT1VQeS/S0/5SZiV7jK8+Z4PLlh+Y7nj9SNxHha59TcaEcsw0zl8GN/1KrBbsuu+Fb+VdGUE04lXs9inIv9Qu+3Fbp2HGSFVffMdfE8=; X-YMail-OSG: 7bzddfkVM1mAdx9gUqTOhe2yO.jzvB5YbSoD4ucY8jhGiBdBoj.w78shadHCdCo8qxVmMewFERxu2tLFbr6IMloumRoj3KNjh4SqbiczQEMTqRYrulTVAJRVt5V0Hny7RPeLm39_gIil.d.ZTzymQGuaUgQltkGJzSYB7qM1uwl8uA-- Original-Received: from [76.203.171.153] by web83204.mail.mud.yahoo.com via HTTP; Sun, 30 Nov 2008 16:10:53 PST X-Mailer: YahooMailWebService/0.7.218.2 In-Reply-To: <87abbg7qvj.fsf@master.homenet> X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) 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:106352 Archived-At: --- On Sun, 11/30/08, Giuseppe Scrivano wrote: > From: Giuseppe Scrivano > Subject: Re: multi-threaded Emacs > To: "Miles Bader" > Cc: rms@gnu.org, emacs-devel@gnu.org > Date: Sunday, November 30, 2008, 11:09 PM > Miles Bader writes: > > > BTW, there was a huge thread maybe a year (?) or so > ago about this subject. > > Have you read it? > > > > IIRC, the basic consensus was that some sort of > explicitly > > non-preemptive threading was probably the best > solution for emacs. > > > > -Miles > > I found a thread of 3 years ago (maybe is it this one? > Time passes very > fast :) ) but I didn't find any conclusion. > > Anyway, a non-preemptive threading will not give any real > parallelism > and it will require more changes in the Elisp packages to > use threads as > they will need to say explicitly when give the control to > another > thread. > Instead `run-in-thread' will setup the call stack and > finally give the > control to the thread. The only change required in the > Elisp packages > to be used in a multithreaded environment is to protect > global data > accesses with a lock/unlock, but how many times does it > happen to change > the value of a global variable? > > Both solutions require changes in Elisp, a non-preemptive > threading > needs to explicitly yield the control to another thread, > while having > real threads needs to specify when access to global data > must be > protected. The latter one differently allows parallelism > and I guess > less changes in the Elisp code too (if writes to global > data are less > frequent than specify when exit from the current thread). > > Giuseppe A non-preemptive threading model can also yield implicitly, but can have unexpected consequences - for example a global variable changing value between two uses within a function, or if two values that are modified together. In general, such transaction semantics have to be coded explicitly in a preemptive threading model, where as with a cooperative model, one has to be aware of only a few of such points. Perhaps these things were discussed earlier. I will take a look. Chetan