From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: SIGPROF + SIGCHLD and igc Date: Sun, 29 Dec 2024 21:05:24 +0200 Message-ID: <86ttampax7.fsf@gnu.org> References: <87o713wwsi.fsf@telefonica.net> <87ldw7fwet.fsf@protonmail.com> <87a5cnfj8t.fsf@protonmail.com> <86seqe4j4f.fsf@gnu.org> <87ttaucub8.fsf@protonmail.com> <87pllicrpi.fsf@protonmail.com> <864j2u442i.fsf@gnu.org> <87a5ch5z1b.fsf@gmail.com> <86y101wlsr.fsf@gnu.org> <87msgeb9y6.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12147"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, pipcet@protonmail.com, ofv@wanadoo.es, emacs-devel@gnu.org, acorallo@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 29 20:06:40 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tRyca-00032t-6N for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Dec 2024 20:06:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRybm-0002Fe-EY; Sun, 29 Dec 2024 14:05:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRybj-0002FW-SE for emacs-devel@gnu.org; Sun, 29 Dec 2024 14:05:47 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRybi-0007zg-CJ; Sun, 29 Dec 2024 14:05:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5ArwoPX83rkNotyViR8dayqwl8/LSh8aor6RFK3SPf0=; b=CgGecKsEl0/g 7ZASB2g3MlAtnnuJarcU9g7CYSU73KyyUfkiIpZ8IJeknQXHzG610qlZTHZlw5a/RFQ4rxz1evq+A CDHw+dZQ11maW0eRr3n80Nfdrncev2g1llX9sZk2f80aJT+CrUzi+Nm91muZVNeC4H7uBfNaKVH/L pcVmf7sTeOyXEGX/8LWWysdA1tfA4V+PUKio+bito5OsQ35cBW958vO5kovFH8q2vtmobVwV/MR/S B/ewPDe62+dZJxB9WDlzgszXO4kVtAhBCfGHOklEfc/cAuJnCL+66kchD8U5qC+iHHGJqz7PZ1N8l Mix/fXdXmd+mkI/fNSllIw==; In-Reply-To: <87msgeb9y6.fsf@gmail.com> (message from Helmut Eller on Sun, 29 Dec 2024 19:50:09 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:327359 Archived-At: > From: Helmut Eller > Cc: gerd.moellmann@gmail.com, pipcet@protonmail.com, ofv@wanadoo.es, > emacs-devel@gnu.org, acorallo@gnu.org > Date: Sun, 29 Dec 2024 19:50:09 +0100 > > On Fri, Dec 27 2024, Eli Zaretskii wrote: > [...] > > You are basically describing the way SIGPROF emulation is implemented > > on Windows (see w32proc.c for the details). But I don't understand > > why you need that pipe: doesn't pthreads allow one thread to stop the > > other? If so, just make the "profiler thread" stop the main thread > > instead of your step 2, and resume the main thread instead of your > > step 4. Am I missing something? > > Here another observation: Let's assume that we can emulate SuspendThread > and ResumeThread on POSIX and MacOS (much like MPS does it). In the > profiler thread we can then simply do: > > SuspendThread () > get_backtrace () > ResumeThread () > > without invoking any SIGPROF handler or the need for > ArenaEnter/ArenaLeave. Yes, we can. But that means changing what the SIGPROF handler does will have no effect, which is bad for maintenance. By contrast, the current MS-Windows implementation does basically the same, but it calls the handler, not its body. Also, I don't quite see why you thing calling get_backtrace directly will have any effect on the need to lock the arena. I'm probably missing something. > The only complication seems to be, that we must avoid deadlocks when MPS > tries to suspend a thread is already suspended by our emulation. If MPS always runs from the main thread, it doesn't (and cannot) suspend the thread. Or maybe I misunderstand which thread do you mean here?