sem: use wd_start_realtime/abstime to replace wd_start

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-08-30 16:45:42 +08:00 committed by Xiang Xiao
parent 4196433888
commit 86869e96c9

View file

@ -94,7 +94,6 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
{
FAR struct tcb_s *rtcb = this_task();
irqstate_t flags;
sclock_t ticks;
int ret = ERROR;
DEBUGASSERT(sem != NULL && abstime != NULL);
@ -132,26 +131,16 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
}
#endif
/* Convert the timespec to clock ticks. We must have interrupts
* disabled here so that this time stays valid until the wait begins.
*
* clock_abstime2ticks() returns zero on success or a POSITIVE errno
* value on failure.
*/
clock_abstime2ticks(clockid, abstime, &ticks);
/* If the time has already expired return immediately. */
if (ticks <= 0)
if (clockid == CLOCK_REALTIME)
{
ret = -ETIMEDOUT;
goto out;
wd_start_realtime(&rtcb->waitdog, abstime,
nxsem_timeout, (uintptr_t)rtcb);
}
else
{
wd_start_abstime(&rtcb->waitdog, abstime,
nxsem_timeout, (uintptr_t)rtcb);
}
/* Start the watchdog */
wd_start(&rtcb->waitdog, ticks, nxsem_timeout, (uintptr_t)rtcb);
/* Now perform the blocking wait. If nxsem_wait() fails, the
* negated errno value will be returned below.