From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.devel Subject: Re: Debugging Emacs with threads Date: Sun, 11 Dec 2016 22:07:11 -0500 Message-ID: <95672299-F7C8-4E48-B147-43AEF7579A57@raeburn.org> References: <83inqqe8kb.fsf@gnu.org> <87pokyju0j.fsf@linux-m68k.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1481512384 25594 195.159.176.226 (12 Dec 2016 03:13:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Dec 2016 03:13:04 +0000 (UTC) Cc: Eli Zaretskii , Tom Tromey , emacs-devel@gnu.org To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 12 04:13:00 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGH2w-00059V-7A for ged-emacs-devel@m.gmane.org; Mon, 12 Dec 2016 04:12:58 +0100 Original-Received: from localhost ([::1]:58335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGH2z-0005YT-08 for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2016 22:13:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGGyk-0002hF-Lw for emacs-devel@gnu.org; Sun, 11 Dec 2016 22:08:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGGyh-0003MN-Gq for emacs-devel@gnu.org; Sun, 11 Dec 2016 22:08:38 -0500 Original-Received: from mail-qk0-f193.google.com ([209.85.220.193]:34380) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGGyh-0003Gq-Ck for emacs-devel@gnu.org; Sun, 11 Dec 2016 22:08:35 -0500 Original-Received: by mail-qk0-f193.google.com with SMTP id y205so9123182qkb.1 for ; Sun, 11 Dec 2016 19:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raeburn-org.20150623.gappssmtp.com; s=20150623; h=subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=GFyrU9vp0Ga+AQbpe6E0TTVslzetwSB02FxsFSCNfYA=; b=x9DUm2meh68gVaYTuXtMkoxO3n83P12a/JBEN/0LXUSwZOhzY/wyp8MYAmKChqdV7u /u/aU7le13VMUGpBmgu1nZ41wnKPVl+gcstsO0PHxGEg8V4vHZgGimTPcJ9fwDRQaipW F/mCwFdMQt5+m2fLYrwFW3mlmr/L5uM65MuBnfHIgJ4OexZnwxLrFZB3g4OR1WO4D2Fd aKLzfQ/4c2KXvGSN26X4UghzTLYcmme5p20CSazSRjdvQVrZrsG69i6gHCoY2bYDoP9F 6xIEPUoEQfv3yOVxfEV8cGU4MA7JY5hsqzzIzVOyUBHKEIlIwZ7sO4FZupG18WsolMJn fI4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=GFyrU9vp0Ga+AQbpe6E0TTVslzetwSB02FxsFSCNfYA=; b=TOOYVzyIWMJMkoEbS4vXHNcRAG49e0h58r8Th3pAN2W5HOxeW2w5Ow98NHr997BFEN yXsQ0WUEq4EPFfEAOae+t883CgiOOBLQU1zd5C3uKIDe17+d8lpB/cduf3ypkhdoAL1Q 7Py8v6Bva+oIQ95Yb+BKSODtAUwhAU3C5/SgtS5VFU+wNmtWdkmJ2qGFMSBwP0bXUbUF qyHYeEITUEPJDwVTNj2VOaqTOVUloL5hFicjMkaogqycj6qB3TDpXCp8f865NG4VJVrB k9CcDtWKHVLq1sMJu5xo5vSBhIB4B5wH1elsv8GBmmJj/aVP7L0qj5E4OCIl4BMDdv4I aIaQ== X-Gm-Message-State: AKaTC02OCrd2W/ViokRQzUlMKwECtwGfb+VpJK2oliP1Rp215JVIKy129A8hhPgM9RSyGg== X-Received: by 10.55.164.5 with SMTP id n5mr78090325qke.307.1481512033729; Sun, 11 Dec 2016 19:07:13 -0800 (PST) Original-Received: from [192.168.23.52] (c-50-138-183-136.hsd1.ma.comcast.net. [50.138.183.136]) by smtp.gmail.com with ESMTPSA id b16sm25603059qkg.41.2016.12.11.19.07.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Dec 2016 19:07:12 -0800 (PST) In-Reply-To: <87pokyju0j.fsf@linux-m68k.org> X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.193 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210323 Archived-At: On Dec 11, 2016, at 11:43, Andreas Schwab wrote: > On Dez 11 2016, Eli Zaretskii wrote: >=20 >> When Emacs stops due to a breakpoint, the thread that is the current >> one is in sync between GDB and Emacs. IOW, the current_thread >> variable describes the same thread on which GDB commands will act. >> But as soon as you say something like "thread 1" at the GDB prompt, >> this synchronization is lost: GDB acts on the thread you specified, >> while current_thread is still pointing at the thread which was the >> current one when Emacs stopped. >=20 > Why isn't current_thread a thread-local variable? Multiple C threads can be running at once, but our current model for = Lisp is that only one thread runs at a time; current_thread is the = indicator of which thread that is, and that=E2=80=99s global to the = process. When we actually decide to start running a different Lisp thread from = the =E2=80=9Ccurrent=E2=80=9D one, we need to save the current dynamic = state (let bindings, etc) and restore that of the alternate thread. The = thread wanting to =E2=80=9Center=E2=80=9D the Lisp environment acquires = the global lock, saves the old thread=E2=80=99s state, updates = current_thread, restores its own state, and does its business. This way, threads can release and re-acquire the global lock without = having to save and restore all their dynamic state each time, which is a = win if we release the lock more often than we actually switch between = Lisp threads. Ken=