From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 60055384601F for ; Tue, 6 Apr 2021 13:30:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 60055384601F Received: by mail-qt1-x832.google.com with SMTP id f12so11108481qtq.4 for ; Tue, 06 Apr 2021 06:30:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dlr5G8mvEg4zVv879tdL7a5gG8hRQwpzS2ybpaqHcTU=; b=qQxicoWegjtIQPywftXy2UESIn08yx+Cx6hpP7EcJkmtO3aapFX2i8guPxrXpsO99u Y4PzwAimU9zbzSHnRkZUkYZV3v033OtTt2aQf+V2hv21C3xvxAlk9inZGTCfkwW/vLaH 3VYp8EoN2VCe/Efpe+u/A5DgDMP8q4VTxSwtVCkyjAF8jKhieGVjCLaM3UshyL/q1RSL YKFx2S3zu4GkAOaROgHGguk3ai+S2WTuH8iRwwa9YjVeafe51lptKjr60jD1LWMY/GOv AH04VV1POVjRMvkBVJ0Iauefo5zmEjHiSavB+0kpjL23AgZUFPjSCeTlrzYTQrcgVy6u Rh8A== X-Gm-Message-State: AOAM532axmevp2PhHXDNPltUdyet07liv6yQxzk0afVWD4lZOrTOIB4Q w+OJWvqlku4gbQ424SOyAHcTyg== X-Google-Smtp-Source: ABdhPJxxl1B/0QiOuiuMfBLpiYPRVkbtV/WtL7xv8M5RAUYa1l0wk8D9FbEzhgId6OqT9BByda6W0g== X-Received: by 2002:ac8:4288:: with SMTP id o8mr26617670qtl.28.1617715848685; Tue, 06 Apr 2021 06:30:48 -0700 (PDT) Received: from [192.168.1.132] ([177.194.41.149]) by smtp.gmail.com with ESMTPSA id q65sm15903244qkb.51.2021.04.06.06.30.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Apr 2021 06:30:47 -0700 (PDT) Subject: Re: sem_timedwait: The semaphore times out when the clock_REALTIME is used. To: y00575850 , Libc-help Cc: carlos@systemhalted.org, wuxu.wu@huawei.com References: <20210406130933.1915-1-yangyanchao6@huawei.com> From: Adhemerval Zanella Message-ID: Date: Tue, 6 Apr 2021 10:30:44 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210406130933.1915-1-yangyanchao6@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 13:30:50 -0000 On 06/04/2021 10:09, y00575850 via Libc-stable wrote: > Dear Carlos, > When I use sem_timedwait, a time jump will cause the semaphore to time out. > While I know that using CLOCK_REALTIME is POSIX-defined behavior, it doesn't > fit the actual meaning of this function.To solve this problem, modify the > sem_timedwait process, for example: add a switch control. > Or add an interface that uses the Clock_MONOTONIC interface. > On glibc 2.30 we added the GNU extension sem_clockwait where you can specify the clock against which the timeout will be measured. (I moved this conversation it to libc-help, libc-stable is usually for discussion regarding backporting and issue against older releases).