Discussion:
sem_timedwait3(..., ..., clockid_t)
Eric van Gyzen
2017-02-15 21:38:52 UTC
Permalink
Would anyone else be interested in me adding a sem_timedwait3() function?

int sem_timedwait3(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);

The clock_id would specify the reference clock for the absolute timeout.
The standard sem_timedwait() API uses CLOCK_REALTIME, which does not
play nicely with large clock adjustments.

I realize it would be non-standard. I also realize that there are
standard APIs that should probably be used instead, such as Pthread
condition variables with pthread_condattr_setclock(3). On the other
hand, the diff is [currently] tiny, so I thought I would offer it.

Cheers,

Eric
Eric van Gyzen
2017-02-15 21:57:37 UTC
Permalink
Post by Eric van Gyzen
Would anyone else be interested in me adding a sem_timedwait3() function?
int sem_timedwait3(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);
The clock_id would specify the reference clock for the absolute timeout.
The standard sem_timedwait() API uses CLOCK_REALTIME, which does not
play nicely with large clock adjustments.
I realize it would be non-standard. I also realize that there are
standard APIs that should probably be used instead, such as Pthread
condition variables with pthread_condattr_setclock(3). On the other
hand, the diff is [currently] tiny, so I thought I would offer it.
kib@ suggested that I use the _np suffix, which is an obviously good
idea, so the proposal is now:

int sem_timedwait3_np(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);

Eric
Ed Schouten
2017-02-16 06:47:06 UTC
Permalink
Hi Eric,
Post by Eric van Gyzen
int sem_timedwait3_np(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);
Could we please make the argument order a bit more consistent to
clock_nanosleep() (i.e., putting the clockid_t in front of the
timespec)? Should we also provide support for the TIMER_ABSTIME flag?
--
Ed Schouten <***@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717
Sebastian Huber
2017-02-16 08:33:27 UTC
Permalink
Post by Ed Schouten
Hi Eric,
Post by Eric van Gyzen
int sem_timedwait3_np(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);
Could we please make the argument order a bit more consistent to
clock_nanosleep() (i.e., putting the clockid_t in front of the
timespec)? Should we also provide support for the TIMER_ABSTIME flag?
Maybe it makes sense to talk also with the glibc and POSIX people

http://www.opengroup.org/austin/
http://austingroupbugs.net/main_page.php
--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : ***@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Eric van Gyzen
2017-02-18 15:32:03 UTC
Permalink
Post by Sebastian Huber
Post by Ed Schouten
Hi Eric,
Post by Eric van Gyzen
int sem_timedwait3_np(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);
Could we please make the argument order a bit more consistent to
clock_nanosleep() (i.e., putting the clockid_t in front of the
timespec)? Should we also provide support for the TIMER_ABSTIME flag?
Maybe it makes sense to talk also with the glibc and POSIX people
http://www.opengroup.org/austin/
http://austingroupbugs.net/main_page.php
It certainly makes sense, at some point. I'll get some agreement within the
FreeBSD community, then take it to glibc and then to POSIX.

Thanks for the suggestions.

Eric

Eric van Gyzen
2017-02-17 21:20:26 UTC
Permalink
Post by Ed Schouten
Hi Eric,
Post by Eric van Gyzen
int sem_timedwait3_np(sem_t *sem, const struct timespec *abs_timeout,
clockid_t clock_id);
Could we please make the argument order a bit more consistent to
clock_nanosleep() (i.e., putting the clockid_t in front of the
timespec)?
Sure. I had made them consistent with sem_timedwait, but your suggestion makes
sense, especially since...
Post by Ed Schouten
Should we also provide support for the TIMER_ABSTIME flag?
That sounds useful. I would also need to add a parameter for returning the
remaining time.

How does this look?

https://reviews.freebsd.org/D9656

I have not yet tested it, so don't spend time on a line-by-line review yet.

Eric
Loading...