From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: Are there plans for a multi-threaded Emacs? Date: Thu, 04 Dec 2003 08:05:15 -0500 Organization: =?koi8-r?q?=F4=C5=CF=C4=CF=D2=20=FA=CC=C1=D4=C1=CE=CF=D7?= @ Cienfuegos Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <4noeuon378.fsf@lockgroove.bwh.harvard.edu> References: <87oevbes4h.fsf@emacswiki.org> <20031117040607.C6C5D79B72@server2.messagingengine.com> <87ekvpx18d.fsf@emptyhost.emptydomain.de> <4nad6cikxy.fsf@holmes.bwh.harvard.edu> <4nllpt3hr3.fsf@lockgroove.bwh.harvard.edu> <5bad69zd43.fsf@lister.roxen.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1070544782 14900 80.91.224.253 (4 Dec 2003 13:33:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 Dec 2003 13:33:02 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Dec 04 14:32:59 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ARtbH-0005yS-00 for ; Thu, 04 Dec 2003 14:32:59 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ARtbG-0007yY-00 for ; Thu, 04 Dec 2003 14:32:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ARuWm-0004C8-9E for emacs-devel@quimby.gnus.org; Thu, 04 Dec 2003 09:32:24 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ARuWH-00049j-S3 for emacs-devel@gnu.org; Thu, 04 Dec 2003 09:31:53 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ARuVk-0003vX-O0 for emacs-devel@gnu.org; Thu, 04 Dec 2003 09:31:51 -0500 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ARu9V-00073Y-2X for emacs-devel@gnu.org; Thu, 04 Dec 2003 09:08:21 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ARtBl-00073G-00 for ; Thu, 04 Dec 2003 14:06:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ARtBk-000738-00 for ; Thu, 04 Dec 2003 14:06:36 +0100 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ARtBk-0002zu-00 for ; Thu, 04 Dec 2003 14:06:36 +0100 Original-Lines: 38 Original-X-Complaints-To: usenet@sea.gmane.org X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (usg-unix-v) Cancel-Lock: sha1:GfpLDIhqPlRK43EJZOYG/VyrhHk= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:18365 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:18365 On Thu, 04 Dec 2003, mast@lysator.liu.se wrote: > What about simply having a single mutex for everything? It's > essentially always held, and a thread only relinquishes it to do > blocking operations. Immediately afterwards it reacquires the lock. > I take it this would essentially be the same as your starting point, > where all functions are synchronous - nothing runs at the same time > as anything else. There are however only small benefits to go > further: > > o To be able to run several threads simultaneously in multicpu or > hyperthreaded systems. > o To get OS level preemption between threads. Those two benefits make a big difference. Today's Pentiums have hyper-threading technology, so even a single processor can act as two. The best cooperative multitasking can't make use of multiple processors as well as premptive multithreading. Cooperative multitasking definitely has benefits - time-critical applications for instance, but I don't think that applies to Emacs. > I see these benefits with this model compared to a "fully" > multithreaded variant: > > o Fairly small changes in the C code. > o No significant change in the elisp execution model, at least not > if preemption is avoided. > o Little overhead in locking - there's no fine grained locking on > individual data structures. I agree with all those. Converting a single-threaded application to multithreaded, especially one as complex as Emacs, is a daunting task. I think it's worthwhile. Ted