From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Experiment with threads - no concurrency? Date: Mon, 06 Sep 2021 18:35:16 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27058"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 06 18:36:33 2021 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 1mNHbk-0006kQ-JH for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Sep 2021 18:36:33 +0200 Original-Received: from localhost ([::1]:47554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNHbi-00035e-BX for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Sep 2021 12:36:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNHac-0001MO-HH for emacs-devel@gnu.org; Mon, 06 Sep 2021 12:35:22 -0400 Original-Received: from mail-oln040092069068.outbound.protection.outlook.com ([40.92.69.68]:34981 helo=EUR02-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNHaa-0004GR-F3 for emacs-devel@gnu.org; Mon, 06 Sep 2021 12:35:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RiCaXdFWG+sDeleFiq14unWgGRdURQgPl24o0K5KasovjJUwQgyA6lJ2YH7csUuLO1znrStOzVMZpU4Bz/VKtZNEDaR9UcnvdAALPUiORn3nqCpha8GnMyVuJC7h0SIG6QbIXSMBKgVZoLLBYWbUwlLYgihtUQcDcSljMHi2IaThzLmVWUattLsbQr8q1nksIGaWWOAqgeVIS9HEpiXwC/vBqauxy4yJN5jDvmvB0x/1INGA7sZe0GVFgmHsq4F+dA8VuG5+Xc3MZIt8jBz0eQarhiubUQJahXDUGzWmrhFeoulxzsjrJyU+TdZMT/KWqkcNqyz6peMqIwbwZZAV8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oSMqtQ8KYXVIeo1JPQQ4zG8BeniQagBA4aZDzOEobuE=; b=E0rKJ2yFIoYhBbyLRHejDhyv17uayPD2Cz2/U7iBtHygDeI7QMkbESXQhrrSxY1/m9saKnYYhe2u3qnN34OvabkXH7RWluFPYB1yZRojS7gOQinTK/9ungsl/enzOgsn3krg6w56LLtt42RoPfpVvQqRwoab/GpYIg+/6ufP3tvXaFPMifR9Q7ZR9ujjSb96j3iyjVltWUBZncxcMq/w0RmZYRhQzaJnnxw/FnDXSGGk+HzC4PgH6nu3jxhUFfmLi/szEGfrp51NgVcAUbKjmcqpJ2QXOV9/kIpHDe6Z1pY/zeJHMfuJjoEsLaw/CnF77ZLno2gQSw8y1+FA3CC/Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oSMqtQ8KYXVIeo1JPQQ4zG8BeniQagBA4aZDzOEobuE=; b=lCiDud+bwvsB+ZbSljq4XPCWnmDENwQGvNCwxA38CBg8MCxcWWcW+p0rJ59m0UyP69AoDExdpeoxsfY3h3hfm/YfB8Edk69Xu6tL6ox4NIsPrII/eY8j+jSHlgEvJJcBAZITqsrOX6mWNU3rtsQiuXWYURc/Iyaop5u9d421osXX35Bh4ZbeIeYeW3JwjacuMIgN075+/7jErbDoBiGzCjDapUzqa+uoeNy9g8FfJD/bZpXvyXDB3mRd69Ow7BuXKyKIT8ZU71O63ZWISAQdT0MYvHvc31Mso9iLCTO1CoD5m3m/AlxUn+m+Z8TfID0L+Ctk/N3v7StLldQJ5uBfSg== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB3347.eurprd09.prod.outlook.com (2603:10a6:208:16d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Mon, 6 Sep 2021 16:35:17 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 16:35:17 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 06 Sep 2021 11:17:00 -0400") X-TMN: [mN63KepNrn6ilcsGEC0Fn9PEhcjI4daF] X-ClientProxiedBy: AS9PR06CA0128.eurprd06.prod.outlook.com (2603:10a6:20b:467::23) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87r1e1u0fv.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by AS9PR06CA0128.eurprd06.prod.outlook.com (2603:10a6:20b:467::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Mon, 6 Sep 2021 16:35:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e78cc4f7-5d95-4031-a712-08d971544f37 X-MS-TrafficTypeDiagnostic: AM0PR09MB3347: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QSZs6Sj/nNYXGHwCOcx9HamYDUe84+tTIrWRImO0RGUEbJHJ6hCUMGTi0WSnNhgtH/rb/gG7B++FxdUnAyUVojwprVtWMYLTdFXdCF1gccHmfWQcbBl5J9TlPQ/n0Wpf0TSkDJoFIS7haZiM1WQGqjyORkn91x7qUTI2Ey0N2Qf6ppxGZ/DEnGHtwtSjqtGIxL5J9YPpIg2Tf0eFWXHf4O5mj1gdbkrna35zhb3zSfMET4KdAnHixArBUScgLdXLdittrmhq48krPWqw1EvE4EP0AdP6tw+tRBeqdqDmnZ/f9l726qy6c2LDm9tFTDXstdtwuqvWIR3Hovjts9lNT55d/e0RDp9nlNgSiQNk3xKO22SMReTUpi99XHRe70fvkh4VFeiBJ8XVLCEnRa4Tde87ODk9Ae7oZV5i59Pzm8jlm6l+W9nv7HnX/rOQkwUJ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XO9C3ykLy90TmTC4LubFWChuE00Ky8YBxwLA8I0DNxjTr7xviza0mqVcADxGyPYt1Jyt4If0v8R1bALQeCR0FkXYruf49yTvhaBQwd7sTzQEzLt9kiT9OeSPv2uLMxbl/x319tCfmSh4kQ9XHn5IiA== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: e78cc4f7-5d95-4031-a712-08d971544f37 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 16:35:17.4355 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3347 Received-SPF: pass client-ip=40.92.69.68; envelope-from=arthur.miller@live.com; helo=EUR02-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:274148 Archived-At: Stefan Monnier writes: >> Since it is kind of lot's of I/O and independent tasks to do, I thought threads >> could come handy. However I see no difference from sequential code. > > This is a common misunderstanding, it seems. Well it woudl be probably misunderstanding on my part, since I thought that threads are just a wrapper on pthreads and tried to translate my thread understanding from other languages. As I am used to, I/O would normally block and threads would be swtiched (in Java). > you tell us what parts of our docs (docstrings or Texinfo manual) you > consulted before coming here? > "Currently, thread switching will occur upon explicit request via thread-yield, when waiting for keyboard input or for process output from asynchronous processes (e.g., during accept-process-output), or during blocking operations relating to threads, such as mutex locking or thread-join." That is the only part that mentions where threads will switch, and it does not mention blocking on I/O so I guess it was misunderstanding on my parts. Maybe it can help guys like me, who assume things based on some previous usage from other places and languages, if you mention this common misunderstanding somewhere, and how Emacs threads compare to some other thread implementations like Java threads or pthreads? This also leaves me with a question: what is practical use for Emacs threads? Is there any internal code that uses threads so I can look at a practical example?