From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 505171F55B for ; Mon, 25 May 2020 20:12:03 +0000 (UTC) Received: from localhost ([::1]:36118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdJS6-0007da-5M for normalperson@yhbt.net; Mon, 25 May 2020 16:12:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdJS2-0007dA-Ha for bug-gnulib@gnu.org; Mon, 25 May 2020 16:11:58 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:40848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdJS1-0004aj-Pl for bug-gnulib@gnu.org; Mon, 25 May 2020 16:11:58 -0400 Received: by mail-pj1-x102c.google.com with SMTP id ci23so309366pjb.5 for ; Mon, 25 May 2020 13:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8MYXHGDAKIn2ph3QeiupGZl/6hsrwwpLDpAtZ+83wLY=; b=jIK8rGM72qBF6HcfmHJX01tt+9POp3GifWdy+5pWjpShJm1XDPDkcPoNgjqe0OugAU XTwbwNoNpsm1yRO5JRqksb8DeSJEe5deP9l2omQJbIuNLMsVoKIOzQxXWU0Q7xpUmeE3 d69ojaoLwEVFTTJ8N/oy6SH9aJikbdm+I3JIdSsc8ktCiBK5i6bMvzgGu//pJ5cq2l8y sJK6AiFYOCTKm5RKBwrm+XSw/EQx3f8fe5RyoMZttpbgAErOlZTi15o4sf7TylqopHuS 0+xa0ss+ih3qphIvmG9ubhyqOvOm5L4B+XUiqVa7lO2gmXvLUFWEo7YveSAACMsRYvV/ 5QJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8MYXHGDAKIn2ph3QeiupGZl/6hsrwwpLDpAtZ+83wLY=; b=Y02758EbIllidBXeTixrPIWlsE+i0VSIdhmmgWN4LfBZNpfndrTjK/dYHwjrb6D80C O8zhLFuybCt0kWPF9g+QN/JPo+d/ydBsg5+CNeP6b+nQG4oEkdKNmhUu3zrBaTKYaRhg GM/oZWUwXuRqIp+Orr04b/eeYHCXL0s0z/kA+Csz3+IOiCJ2XX5TQWU/EyT9/8y9uf2u Ysdtiub1XJhmJST7n0DKgTbZ6DGyFs5kv9bBwox0i70vnIvoPTtf6+tvkctiLdi9SOBW itsdh7FJXt0m4W0tIbSJHSSVfy4GXCnfIkTqh35PKOsgGBqGo+M9vxASBk9hJwVfktUa PwvQ== X-Gm-Message-State: AOAM532vHUi6o/51J2ve2uE1ZMqBsGhBmB3aAPgPf6qyU9Ea6nCEb69x A46Kl2Hbi8W5KpqbGVZXNb8AXqXcfg6c/ErgwYo= X-Google-Smtp-Source: ABdhPJyR/4/etBx+Hgh03XYI+5G0XGunh/1Vvzp2wCYdOGXVD4nDTnceARSjoflblwV8UawaQpfCWHTmX8er7mITQvg= X-Received: by 2002:a17:902:a515:: with SMTP id s21mr29745644plq.334.1590437515370; Mon, 25 May 2020 13:11:55 -0700 (PDT) MIME-Version: 1.0 References: <3693477.VlezqqQ6Ty@omega> <2291895.3fLFq5TaVb@omega> In-Reply-To: <2291895.3fLFq5TaVb@omega> From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Mon, 25 May 2020 22:11:44 +0200 Message-ID: Subject: Re: Module suggestion: Atomic operations To: Bruno Haible Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=marc.nieper@gmail.com; helo=mail-pj1-x102c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Bruno, Am Mo., 25. Mai 2020 um 09:24 Uhr schrieb Bruno Haible : > Pools have the drawback that they add a configuration requirement on the > application: What is the default size of the pool? When to increase the > pool size? By how much? When to shrink the pool? The developer would have > determine good answers to this, but 5 years later or under specific > circumstances the answers may not be good enough. (*) For general types, the gcc (and clang) implementations use general locks coming from a pool. (In the gcc case, see libatomic and, especially, libat_lock_n.) Nevertheless, I agree with you that a pool is suboptimal. > Yes, that's the better way to approach it, then. There is one problem with providing some emulation with Posix locks, though. At least one type in is guaranteed to be lock-free, the atomic flag. Since C18, it can be used in signal handlers, where Posix locks won't work because they are not async-safe. Moreover, provides memory fences, which I don't know how to emulate in general and which also seem to be crucial in signal handlers of multithreaded applications. It seems to me that a substitute of needs to know a bit about the underlying compiler (so that builtins can be used) or the underlying architecture (for example, x86 does not need memory fences with the release or acquire memory order. Unfortunately, my knowledge about other compilers than gcc or other architectures than x86 is limited. I could provide the skeleton of a substitute, but it would need other people to add their architectures. Marc