> On Nov 4, 2018, at 5:32 AM, Mike Crowe <theopengr...@mac.mcrowe.com> wrote:
> 
> * The problem:
> 
> POSIX functions that take an absolute time point as a timeout parameter use
> the CLOCK_REALTIME clock. This clock can be warped, particularly on
> personal or embedded devices, which makes it unsuitable for use for
> timeouts. A more suitable clock is CLOCK_MONOTONIC.
> 
> C++ standard classes such as std::condition_variable and std::timed_mutex
> treat the clock to use as being part of the wait operation, rather than as
> initialisation parameters of the underlying condition variable or mutex.
> This means that the solution currently exposed through
> pthread_condattr_setclock does not work well.
> 
> * Affected functions:
> 
> sem_timedwait
> pthread_mutex_timedlock
> pthread_cond_timedwait
> pthread_rwlock_timedrdlock
> pthread_rwlock_timedwrlock
> mq_timedreceive
> mq_timedsend
> 
> (posix_trace_timedgetnext_event is also affected, but the header containing
> thatfunction is marked "obsolescent".)
> 
> * Proposed solution:
> 
> Create alternative forms of the affected functions that also take a
> parameter of type clockid_t to indicate the clock that should be used. The
> only clock that must be supported by implementations is CLOCK_REALTIME.
> Passing an unsupported clock will yield EINVAL. THis means that
> implementations that do not wish to support alternative clocks can just
> check the clock parameter is CLOCK_REALTIME and then call their existing
> function. Better implementations can support CLOCK_MONOTONIC, or perhaps
> even other clocks if appropriate. (The Linux system calls used to implement
> mq_clockreceive and mq_clocksend do not currently support CLOCK_MONOTONIC.)
> 
> (It would be desirable to require CLOCK_MONOTONIC support too, but I
> wouldn't want this proposal to be stalled by implementors who will not or
> cannot support it.)
> 
> * Function naming:
> 
> Several    proposals have been made for naming:
> 
> ** 1. clock prefix
> sem_clock_timedwait
> pthread_mutex_clock_timedlock
> pthread_cond_clock_timedwait
> pthread_rwlock_clock_timedrdlock
> pthread_rwlock_clock_timedwrlock
> mq_clock_timedreceive
> mq_clock_timedsend
> 
> ** 2. timed->clock
> sem_clockwait
> pthread_mutex_clocklock
> pthread_rwlock_clockrdlock
> pthread_rwlock_clockwrlock
> mq_clockreceive
> mq_clocksend
> pthread_cond_clockwait

My preference is option 2, as it's less wordy.

> ** 3. onclock suffix
> sem_timedwait_onclock
> pthread_mutex_timedlock_onclock
> pthread_rwlock_timedrdlock_onclock
> pthread_rwlock_timedwrlock_onclock
> mq_timedreceive_onclock
> mq_timedsend_onclock
> pthread_cond_timedwait_onclock
> 
> (suffices of simply _clock, or _cid were also proposed)

--
DE

Reply via email to