From patchwork Mon Jun 19 22:20:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 1796828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=oGGIoxe5; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QlPPN15Mcz20XS for ; Tue, 20 Jun 2023 08:21:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE3883856954 for ; Mon, 19 Jun 2023 22:21:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE3883856954 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213285; bh=cqIkEL/x4EHFntYa3JFbQOGneRe/fJWpN8VrLbA8QB8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=oGGIoxe5u4/flPSWhj95MAojDDjJ3jASOUuKz0D/aewSg5h3w+KMuwqBLK8nnKI7t YO7uiX7JyUPl5nz2efJaHgNbNX0C9qNunvpioW/CNsdSw7SQ6udoDbbkpmuc1F/y2d JltfzZ2J3ADUmCbmmwCDoFX1oMUdfEr96nkc/MHI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id AFEFC3858D1E for ; Mon, 19 Jun 2023 22:21:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFEFC3858D1E Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-666ecb21f86so3013925b3a.3 for ; Mon, 19 Jun 2023 15:21:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213266; x=1689805266; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cqIkEL/x4EHFntYa3JFbQOGneRe/fJWpN8VrLbA8QB8=; b=QlD5j1jcKCH52QKsQwZ2dAY/3wIQA2nfngvqEvHOHitb8ha/TPCewoDc+RkkWF+lhw jmh70N3r22TT4I8tti134Das+nyNgbeWkLKmoHx2JMSTOpHawi6i8ov8j48x6ZF9RjPM EwHLvNkpGJs4YcwBmHqd6KPt2ILIxnoiJvfDtufv/8JUIBxxQJQzCqJ3SHxE76zgnUmN HtLIlI4HdODLCA15dh1UglySyeh/h0POXUueHTU2hXvPR59Y7EkLhZy8VFdADWU+t354 PHswzNfKr/bOhRLcvtsoUvkqTxqSWHQH74+xOATqEf6XxSJ/9vLx3lFFEmSxWWNWK58M f2Cw== X-Gm-Message-State: AC+VfDyT/nNugw44Go1hNhyS0FHq4NWmBkLttD9HoxkLMJB5MmMBtBnU DoI3P4EcfsSbkNbFbiS7h1JH+nUQKF1t4w== X-Google-Smtp-Source: ACHHUZ5xCRm4pa1HBFxZd8Ua8tYzHOK/OFmdaMvMk2ZxFXO3ZJ3iKNeXnWJ8peyk9ZR8Peg3Mxc7+Q== X-Received: by 2002:a05:6a00:2301:b0:64b:205:dbf3 with SMTP id h1-20020a056a00230100b0064b0205dbf3mr16732997pfh.34.1687213266581; Mon, 19 Jun 2023 15:21:06 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y17-20020a63e251000000b0050a0227a4bcsm161387pgj.57.2023.06.19.15.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:06 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 0/5] c2y proposal add monotonicwait support for mtx and ctx Date: Tue, 20 Jun 2023 06:20:47 +0800 Message-Id: <20230619222052.682-1-luoyonggang@gmail.com> X-Mailer: git-send-email 2.39.0.windows.1 MIME-Version: 1.0 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Libc-alpha From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Currently the c11 threads mtx and cnd only support for mtx_timedlock and cnd_timedwait that use TIME_UTC, and it's not monotonic, for application want monotonic wait/lock, then they can not use c11 threads, So here I proposaled functions: int mtx_timedlock_monotonic( mtx_t *restrict mutex, const struct timespec *restrict time_point ); int cnd_timedwait_monotonic( cnd_t* restrict cond, mtx_t* restrict mutex, const struct timespec* restrict time_point ); to support monotonic lock/wait for mtx/cnd . Yonggang Luo (5): features: Rename __GLIBC_USE_ISOC2X to __GLIBC_USE_ISOC23 time: Implement c23 timespec_get base clang-format: should format with 2 space and do not usage tab c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait to implement cnd and mtx lock and wait c2y: Add function cnd_timedwait_monotonic and mtx_timedlock_monotonic .clang-format | 4 +- conform/data/threads.h-data | 2 + include/features.h | 4 +- nptl/Versions | 5 + sysdeps/pthread/Makefile | 2 + sysdeps/pthread/cnd_timedwait.c | 8 +- ..._timedwait.c => cnd_timedwait_monotonic.c} | 58 +++++----- sysdeps/pthread/mtx_timedlock.c | 6 +- ..._timedlock.c => mtx_timedlock_monotonic.c} | 56 +++++----- sysdeps/pthread/threads.h | 16 +++ sysdeps/unix/sysv/linux/Versions | 6 ++ sysdeps/unix/sysv/linux/cnd_timedwait.c | 4 +- ..._timedwait.c => cnd_timedwait_monotonic.c} | 18 ++-- sysdeps/unix/sysv/linux/mtx_timedlock.c | 4 +- ..._timedlock.c => mtx_timedlock_monotonic.c} | 100 +++++++++--------- sysdeps/unix/sysv/linux/thrd_priv.h | 8 ++ time/time.h | 13 +++ time/timespec_get.c | 48 ++++++++- 18 files changed, 228 insertions(+), 134 deletions(-) copy sysdeps/pthread/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (70%) copy sysdeps/pthread/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (75%) copy sysdeps/unix/sysv/linux/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (68%) copy sysdeps/unix/sysv/linux/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (59%)