wangchdo commented on PR #17489:
URL: https://github.com/apache/nuttx/pull/17489#issuecomment-3658444187
@xiaoxiang781216 @anchao @acassis @simbit18 @cederom
Per @xiaoxiang781216’s comments, I have updated the critical section
protection for hrtimer to use a spinlock to improve performance.
However, to prevent potential issues where hrtimer_cancel() might cancel a
running timer and the timer instance could be freed prematurely, I have
introduced a state machine for hrtimer:
```
INACTIVE
|
| start
v
ARMED -------- cancel --------> CANCELED
| ^
| expire |
v |
RUNNING -------- cancel ----------+
|
| return
v
INACTIVE
```
**Key points:**
1. hrtimer_cancel() remains non-blocking.
2. If the timer callback is currently executing, it is allowed to complete.
3. After cancellation, the callback will not be invoked again.
4. The caller must ensure that timer-related resources are not freed until
the callback has returned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]