public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Rachid Koucha <rachid.koucha@gmail.com>
To: libc-alpha@sourceware.org
Subject: About pthread_yield() implementation
Date: Sun, 20 Dec 2020 20:03:18 +0100	[thread overview]
Message-ID: <9d6ae6c9-0f57-94dc-2a4d-64d63a44a117@gmail.com> (raw)

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.


||

||

             reply	other threads:[~2020-12-20 19:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 19:03 Rachid Koucha [this message]
2020-12-21 17:57 ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d6ae6c9-0f57-94dc-2a4d-64d63a44a117@gmail.com \
    --to=rachid.koucha@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).