Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_umtx.c
Show First 20 Lines • Show All 766 Lines • ▼ Show 20 Lines | |||||
abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute, | abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute, | ||||
const struct timespec *timeout) | const struct timespec *timeout) | ||||
{ | { | ||||
timo->clockid = clockid; | timo->clockid = clockid; | ||||
if (!absolute) { | if (!absolute) { | ||||
timo->is_abs_real = false; | timo->is_abs_real = false; | ||||
abs_timeout_update(timo); | abs_timeout_update(timo); | ||||
timo->end = timo->cur; | timespecadd(&timo->cur, timeout, &timo->end); | ||||
timespecadd(&timo->end, timeout); | |||||
} else { | } else { | ||||
timo->end = *timeout; | timo->end = *timeout; | ||||
timo->is_abs_real = clockid == CLOCK_REALTIME || | timo->is_abs_real = clockid == CLOCK_REALTIME || | ||||
clockid == CLOCK_REALTIME_FAST || | clockid == CLOCK_REALTIME_FAST || | ||||
clockid == CLOCK_REALTIME_PRECISE; | clockid == CLOCK_REALTIME_PRECISE; | ||||
/* | /* | ||||
* If is_abs_real, umtxq_sleep will read the clock | * If is_abs_real, umtxq_sleep will read the clock | ||||
* after setting td_rtcgen; otherwise, read it here. | * after setting td_rtcgen; otherwise, read it here. | ||||
Show All 21 Lines | |||||
static int | static int | ||||
abs_timeout_gethz(struct abs_timeout *timo) | abs_timeout_gethz(struct abs_timeout *timo) | ||||
{ | { | ||||
struct timespec tts; | struct timespec tts; | ||||
if (timespeccmp(&timo->end, &timo->cur, <=)) | if (timespeccmp(&timo->end, &timo->cur, <=)) | ||||
return (-1); | return (-1); | ||||
tts = timo->end; | timespecsub(&timo->end, &timo->cur, &tts); | ||||
timespecsub(&tts, &timo->cur); | |||||
return (tstohz(&tts)); | return (tstohz(&tts)); | ||||
} | } | ||||
static uint32_t | static uint32_t | ||||
umtx_unlock_val(uint32_t flags, bool rb) | umtx_unlock_val(uint32_t flags, bool rb) | ||||
{ | { | ||||
if (rb) | if (rb) | ||||
▲ Show 20 Lines • Show All 2,418 Lines • ▼ Show 20 Lines | do_sem2_wait(struct thread *td, struct _usem2 *sem, struct _umtx_time *timeout) | ||||
else { | else { | ||||
umtxq_remove(uq); | umtxq_remove(uq); | ||||
if (timeout != NULL && (timeout->_flags & UMTX_ABSTIME) == 0) { | if (timeout != NULL && (timeout->_flags & UMTX_ABSTIME) == 0) { | ||||
/* A relative timeout cannot be restarted. */ | /* A relative timeout cannot be restarted. */ | ||||
if (error == ERESTART) | if (error == ERESTART) | ||||
error = EINTR; | error = EINTR; | ||||
if (error == EINTR) { | if (error == EINTR) { | ||||
abs_timeout_update(&timo); | abs_timeout_update(&timo); | ||||
timeout->_timeout = timo.end; | timespecsub(&timo.end, &timo.cur, | ||||
timespecsub(&timeout->_timeout, &timo.cur); | &timeout->_timeout); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
umtxq_unlock(&uq->uq_key); | umtxq_unlock(&uq->uq_key); | ||||
umtx_key_release(&uq->uq_key); | umtx_key_release(&uq->uq_key); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,308 Lines • Show Last 20 Lines |