unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mike Crowe <mac@mcrowe.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
Date: Tue, 8 Oct 2019 09:26:04 +0100	[thread overview]
Message-ID: <20191008082604.GA24571@mcrowe.com> (raw)
In-Reply-To: <3b240188c00f3e6471d1ddeec2dfee80515da222.1568809830.git-series.mac@mcrowe.com>

On Wednesday 18 September 2019 at 13:30:55 +0100, Mike Crowe wrote:
> Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that
> accepts a clockid_t parameter to indicate which clock the timeout should be
> measured against. This mirrors the recently-added POSIX-proposed "clock"
> wait functions.

[snip]

> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> index a4ae459..c06e65a 100644
> --- a/nptl/tst-join3.c
> +++ b/nptl/tst-join3.c
> @@ -28,6 +28,8 @@
>  #include <support/xtime.h>
>  
>  
> +#define CLOCK_USE_TIMEDJOIN (-1)
> +
>  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>  
>  
> @@ -35,19 +37,23 @@ static void *
>  tf (void *arg)
>  {
>    xpthread_mutex_lock (&lock);
> +  xpthread_mutex_unlock (&lock);
>  
>    return (void *) 42l;
>  }
>  
>  
>  static int
> -do_test (void)
> +do_test_clock (clockid_t clockid)
>  {
> +  const clockid_t clockid_for_get =
> +    (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid;
> +
>    xpthread_mutex_lock (&lock);
>    pthread_t th = xpthread_create (NULL, tf, NULL);
>  
>    void *status;
> -  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +  struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
>                                            make_timespec (0, 200000000));
>  
>    int val = pthread_timedjoin_np (th, &status, &timeout);

This needs to call pthread_clockjoin_np if clockid indicates so, as below.

> @@ -57,10 +63,13 @@ do_test (void)
>  
>    while (1)
>      {
> -      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +      timeout = timespec_add (xclock_now (clockid_for_get),
>                                make_timespec (0, 200000000));
>  
> -      val = pthread_timedjoin_np (th, &status, &timeout);
> +      if (clockid == CLOCK_USE_TIMEDJOIN)
> +        val = pthread_timedjoin_np (th, &status, &timeout);
> +      else
> +        val = pthread_clockjoin_np (th, &status, clockid, &timeout);
>        if (val == 0)
>  	break;
>  
> @@ -73,4 +82,13 @@ do_test (void)
>    return 0;
>  }
>  
> +static int
> +do_test (void)
> +{
> +  do_test_clock (CLOCK_USE_TIMEDJOIN);
> +  do_test_clock (CLOCK_REALTIME);
> +  do_test_clock (CLOCK_MONOTONIC);
> +  return 0;
> +}
> +
>  #include <support/test-driver.c>

Mike.

  parent reply	other threads:[~2019-10-08  8:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
2019-09-26 20:45   ` Adhemerval Zanella
2019-09-18 12:30 ` [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np Mike Crowe
2019-09-26 21:26   ` Adhemerval Zanella
2019-09-27  9:08     ` Yann Droneaud
2019-09-28  8:53     ` Mike Crowe
2019-10-14 19:15       ` Adhemerval Zanella
2019-10-18 16:28         ` Mike Crowe
2019-10-21 18:15           ` Adhemerval Zanella
2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
2019-09-26 23:17   ` Adhemerval Zanella
2019-09-28 19:45     ` Mike Crowe
2019-10-14 19:16       ` Adhemerval Zanella
2019-10-08  8:26   ` Mike Crowe [this message]
2019-09-18 12:30 ` [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test Mike Crowe
2019-09-26 23:30   ` Adhemerval Zanella
2019-10-31 14:31 ` [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Adhemerval Zanella
2019-10-31 19:38   ` Mike Crowe
2019-10-31 20:51     ` Adhemerval Zanella
2019-11-01 21:05       ` Joseph Myers
2019-11-01 23:01       ` Rafal Luzynski
2019-11-02  9:14         ` Mike Crowe

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=20191008082604.GA24571@mcrowe.com \
    --to=mac@mcrowe.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).