A NOTE has been added to this issue. 
====================================================================== 
http://austingroupbugs.net/view.php?id=1216 
====================================================================== 
Reported By:                mikecrowe
Assigned To:                ajosey
====================================================================== 
Project:                    1003.1(2016)/Issue7+TC2
Issue ID:                   1216
Category:                   System Interfaces
Type:                       Enhancement Request
Severity:                   Comment
Priority:                   normal
Status:                     Under Review
Name:                       Mike Crowe 
Organization:                
User Reference:              
Section:                    pthread 
Page Number:                0 
Line Number:                0 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2018-11-26 18:53 UTC
Last Modified:              2019-01-19 04:08 UTC
====================================================================== 
Summary:                    Adding clockid parameter to functions that accept
absolute struct timespec timeouts
======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0001164 Correct C++11 std::condition_variable r...
====================================================================== 

---------------------------------------------------------------------- 
 (0004215) mikecrowe (reporter) - 2019-01-19 04:08
 http://austingroupbugs.net/view.php?id=1216#c4215 
---------------------------------------------------------------------- 
Here's my suggested wording for pthread_cond_clockwait (with a single hint
to the other new functions too.) It would be great to receive feedback on
whether the changes are broadly appropriate, and whether there is a better
way to describe the changes. Once I know whether I'm on the right track, I
can add the remaining functions (which will hopefully require fewer
changes.)

(I have glibc implementations of sem_clockwait, pthread_mutex_clockwait,
pthread_cond_clockwait, pthread_rwlock_clockrdlock and
pthread_rwlock_clockwrlock working. I just need to get the commit messages
into shape before posting them to the glibc list.)

Thanks.

Mike.

*** Add to lists at lines 3070, 10833, 18119, 52281, 52599, 52710, 55292,
124395, 130171:
pthread_cond_clockwait()

*** After line 10727 insert:
int pthread_cond_clockwait(pthread_cond_t *restrict,
    pthread_mutex_t *restrict, clockid_t,
    const struct timespec *restrict);

*** After line 10767 insert:
It calls pthread_cond_clockwait() with m as the mutex argument and the call
returns zero or
certain error numbers (see pthread_cond_clockwait()).

*** After line 17972 insert:
It blocks in a call to pthread_cond_clockwait() with m as the mutex
argument.

*** Line 30449
Change "and pthread_cond_timedwait" to ", pthread_cond_timedwait and
pthread_cond_clockwait".

*** Lines 52513, 52515, 52519, 52582, 124488
Change "or pthread_cond_timedwait" to ", pthread_cond_timedwait or
pthread_cond_clockwait".

*** After line 52743 insert:
int pthread_cond_clockwait(pthread_cond_t *restrict cond,
    pthread_mutex_t *restrict mutex,
    clockid_t clock_id,
    const struct timespec *restrict abstime);

*** Lines 52747, 52762, 52763, 52766, 52781, 52783, 52786, 52848, 52882
Add ", pthread_cond_clockwait()" after "pthread_cond_timedwait()"

*** After line 52797 insert:
The pthread_cond_clockwait() function shall be equivalent to
pthread_cond_timedwait(), except that the absolute time specified by
abstime is measured against the clock indicated by clock_id rather than
the
clock specified in the condition variable's clock attribute. All
implementations shall support passing CLOCK_REALTIME to
pthread_cond_clockwait() as the clock_id parameter. If the Monotonic Clock
option is supported, all implementations shall support a clock_id of
CLOCK_MONOTONIC.

*** Line 52822:
Change to "The pthread_cond_timedwait() and pthread_cond_clockwait()
functions shall fail if:"

*** Line 52823, 52850:
Change "pthread_cond_timedwait()" to "pthread_cond_timedwait() or
pthread_cond_clockwait()"

*** Line 52825:
Add "or the clock_id parameter passed to pthread_cond_clockwait is invalid
or not supported."

*** Insert after line 52879:
Choice of clock

Care should be taken to decide which clock is most appropriate when
waiting
with a timeout. The system clock, CLOCK_REALTIME, as used by default with
pthread_cond_timedwait() may be subject to jumps forwards and backwards in
order to correct it against actual time. CLOCK_MONOTONIC is guaranteed not
to jump backwards and must also advance in real time, so using it via
pthread_cond_clockwait() or pthread_condattr_setclock() may be
more appropriate.

*** Line 52943:
Replace CLOCK_REALTIME with CLOCK_MONOTONIC

*** Line 52947:
Replace line with:
 rc = pthread_cond_clockwait(&t.cond, &t.mn, CLOCK_MONOTONIC, &ts);

*** After line line 52956 insert:
Using CLOCK_MONOTONIC rather than CLOCK_REALTIME means that the timeout is
not influenced by the system clock being changed.

*** After line 53084 insert:
Note that the /clock/ attribute shall have no effect on the
pthread_cond_clockwait() function.

*** Lines 54147, 54186, 54321, 55282:
After "pthread_cond_timedwait()" insert ", pthread_cond_clockwait()".

*** Line 123502:
Delete remainder of paragraph starting with "This capability has not been
added to other functions...". Insert in its place:

For condition variables, this capability is also available by passing
CLOCK_MONOTONIC to the pthread_cond_clockwait() function. Similarly,
CLOCK_MONOTONIC can be specified when calling sem_clockwait,
pthread_mutex_clocklock, pthread_rwlock_clockrdlock and
pthread_rwlock_clockwrlock.

*** After line 123535:
Subsequently, it was discovered that using a particular clock for the
timeout was desired by some users. In particular, the ISO C++11 standard
requires the clock to be a property of the wait for its
std::condition_variable and std::timed_mutex. This led to the addition of
sem_clockwait(), pthread_mutex_clockwait(), pthread_cond_clockwait(),
pthread_rwlock_clockrdlock() and pthread_rwlock_clockwrlock() functions
that accepted a clock parameter to measure their absolute timeout against.
The addition of the corresponding mq_clockreceive and mq_clocksend may be
considered in the future. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2018-11-26 18:53 mikecrowe      New Issue                                    
2018-11-26 18:53 mikecrowe      Status                   New => Under Review 
2018-11-26 18:53 mikecrowe      Assigned To               => ajosey          
2018-11-26 18:53 mikecrowe      Name                      => Mike Crowe      
2018-11-26 18:53 mikecrowe      Section                   => pthread         
2018-11-26 18:53 mikecrowe      Page Number               => 0               
2018-11-26 18:53 mikecrowe      Line Number               => 0               
2018-11-27 09:23 geoffclare     Project                  1003.1(2008)/Issue 7 =>
1003.1(2016)/Issue7+TC2
2018-11-27 09:23 geoffclare     Relationship added       related to 0001164  
2018-11-27 16:02 nick           Note Added: 0004171                          
2019-01-07 21:26 mikecrowe      Note Added: 0004196                          
2019-01-19 04:08 mikecrowe      Note Added: 0004215                          
======================================================================


Reply via email to