mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
sched/hrtimer: Simplify the hrtimer_cancel.
This commit simplified the hrtimer_cancel. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
committed by
GUIDINGLI
parent
4d283260ab
commit
a6d64a1a83
@@ -94,16 +94,16 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
|
|||||||
if (hrtimer_is_armed(hrtimer))
|
if (hrtimer_is_armed(hrtimer))
|
||||||
{
|
{
|
||||||
hrtimer_remove(hrtimer);
|
hrtimer_remove(hrtimer);
|
||||||
}
|
|
||||||
|
|
||||||
/* If the canceled timer was the earliest one, update the hardware timer */
|
/* Update the hardware timer if the queue head changed. */
|
||||||
|
|
||||||
if (hrtimer_is_first(hrtimer))
|
if (hrtimer_is_first(hrtimer))
|
||||||
{
|
|
||||||
first = hrtimer_get_first();
|
|
||||||
if (first != NULL)
|
|
||||||
{
|
{
|
||||||
hrtimer_reprogram(first->expired);
|
first = hrtimer_get_first();
|
||||||
|
if (first != NULL)
|
||||||
|
{
|
||||||
|
hrtimer_reprogram(first->expired);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ void hrtimer_process(uint64_t now)
|
|||||||
|
|
||||||
flags = write_seqlock_irqsave(&g_hrtimer_lock);
|
flags = write_seqlock_irqsave(&g_hrtimer_lock);
|
||||||
|
|
||||||
hrtimer_mark_running(NULL, cpu);
|
|
||||||
|
|
||||||
/* If the timer is periodic and has not been rearmed or
|
/* If the timer is periodic and has not been rearmed or
|
||||||
* cancelled concurrently,
|
* cancelled concurrently,
|
||||||
* compute next expiration and reinsert into container
|
* compute next expiration and reinsert into container
|
||||||
@@ -129,7 +127,7 @@ void hrtimer_process(uint64_t now)
|
|||||||
|
|
||||||
if (period != 0u && hrtimer_is_running(hrtimer, cpu))
|
if (period != 0u && hrtimer_is_running(hrtimer, cpu))
|
||||||
{
|
{
|
||||||
hrtimer->expired += period;
|
hrtimer->expired = expired + period;
|
||||||
|
|
||||||
/* Ensure no overflow occurs */
|
/* Ensure no overflow occurs */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user