From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 7DECA3857804 for ; Sun, 20 Dec 2020 19:03:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7DECA3857804 Received: by mail-wr1-x432.google.com with SMTP id 91so8642057wrj.7 for ; Sun, 20 Dec 2020 11:03:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=8h621GT7kZEK50LiyuFqh73O6EfadVfu0webkiIUMLY=; b=PLN2DHg7H+o7iJM6zh0qRiQsz0Usknl+HR29FpBGv5DQKk6TTHpOJRtzaz4bSG8dBz xJepz3Izx2lIvzXBV2zo8MmAyzKlKPdYkp0biGLQjzTOPG0YCafz7u6FpSGuY84EqM19 2v/v6p9M8dryXH/aGA7VPypSRxe/YwU5NM7gFgbyJo3Cb02CFL7yAn5NWmhJkzN+qeM2 wZYfomExYC+2ScpImlbzxxGzjX1EMZp5YFGSl89QzvaUZ1sVI/lM2EbLFmumyisDIti4 3ZjGmkpfu7r5PxjwAjwM/eNQL8AFbG44gisMvsPN+gS13feKGUOcoPlhnixGmNYW+bTp 2ZcQ== X-Gm-Message-State: AOAM530tBD6cX3q+46p3SSAIBkwrCdFZg/rppiZCutoSMuA2xpHH5G11 LsWOEhkDLJzsLi93gi5i3X+rhWFNBq8= X-Google-Smtp-Source: ABdhPJwX4ECiHX62r9fMwrTztuHw3ETepMnHCIlGPxutiM7HjMxRJhtKY0jekljdEnw31wN9FxJYoA== X-Received: by 2002:a5d:51cc:: with SMTP id n12mr14614238wrv.375.1608491000105; Sun, 20 Dec 2020 11:03:20 -0800 (PST) Received: from ?IPv6:2a01:e0a:2b6:5c60:58c7:b7b0:a19c:e29d? ([2a01:e0a:2b6:5c60:58c7:b7b0:a19c:e29d]) by smtp.gmail.com with ESMTPSA id a14sm23020548wrn.3.2020.12.20.11.03.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Dec 2020 11:03:19 -0800 (PST) To: libc-alpha@sourceware.org From: Rachid Koucha Subject: About pthread_yield() implementation Message-ID: <9d6ae6c9-0f57-94dc-2a4d-64d63a44a117@gmail.com> Date: Sun, 20 Dec 2020 20:03:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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-List-Received-Date: Sun, 20 Dec 2020 19:03:22 -0000 Hi, Answering a question about pthread_yield() on StackOverflow web site, I realize that there is a possible implementation bug for this function (in the GLIBC 2.31 at least): The source code of the service is: |/* With the 1-on-1 model we implement this function is equivalent to the 'sched_yield' function. */ int pthread_yield (void) { return sched_yield (); } | ||||But this results in a unusual pthread API behavior which *may be an implementation bug* as it returns directly the result of /sched_yield()/. Like most of the Linux system calls, the latter returns -1 and sets *errno* if it fails (even if the manual specifies that it actually never returns in error). So, theoretically, this makes /pthread_yield()/ return -1 and set *errno* in case of error although the pthread API usually returns 0 if successful and the error number in case of error (*errno* is not supposed to be set). So, the manual is wrong or at least does not comply with the GLIBC's implementation when it describes the returned value as: RETURN VALUE On success, pthread_yield() returns 0; on error, it returns an error number. Regards, Rachid. || ||