Add sem_clockwait_np()

This function allows the caller to specify the reference clock
and choose between absolute and relative mode.  In relative mode,
the remaining time can be returned.

The API is similar to clock_nanosleep(3).  Thanks to Ed Schouten
for that suggestion.

While I'm here, reduce the sleep time in the semaphore "child"
test to greatly reduce its runtime.  Also add a reasonable timeout.

Reviewed by:	ed (userland)
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9656
This commit is contained in:
Eric van Gyzen
2017-02-23 19:36:38 +00:00
parent af67ca3780
commit b215ceaaec
10 changed files with 299 additions and 43 deletions
+2
View File
@@ -59,6 +59,8 @@ int sem_init(sem_t *, int, unsigned int);
sem_t *sem_open(const char *, int, ...);
int sem_post(sem_t *);
int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
int sem_clockwait_np(sem_t * __restrict, __clockid_t, int,
const struct timespec *, struct timespec *);
int sem_trywait(sem_t *);
int sem_unlink(const char *);
int sem_wait(sem_t *);