🎈 perf(ktime): perf hrtimer, del wrong function (#7880)

This commit is contained in:
xqyjlj 2023-08-16 15:32:46 +08:00 committed by GitHub
parent 93388f8045
commit aa300c4c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 27 deletions

View File

@ -25,6 +25,7 @@ struct rt_ktime_hrtimer
void *parameter; void *parameter;
unsigned long init_cnt; unsigned long init_cnt;
unsigned long timeout_cnt; unsigned long timeout_cnt;
rt_err_t error;
struct rt_semaphore sem; struct rt_semaphore sem;
void (*timeout_func)(void *parameter); void (*timeout_func)(void *parameter);
}; };
@ -125,12 +126,18 @@ void rt_ktime_hrtimer_init(rt_ktime_hrtimer_t timer,
rt_uint8_t flag, rt_uint8_t flag,
void (*timeout)(void *parameter), void (*timeout)(void *parameter),
void *parameter); void *parameter);
rt_err_t rt_ktime_hrtimer_delete(rt_ktime_hrtimer_t timer);
rt_err_t rt_ktime_hrtimer_start(rt_ktime_hrtimer_t timer); rt_err_t rt_ktime_hrtimer_start(rt_ktime_hrtimer_t timer);
rt_err_t rt_ktime_hrtimer_stop(rt_ktime_hrtimer_t timer); rt_err_t rt_ktime_hrtimer_stop(rt_ktime_hrtimer_t timer);
rt_err_t rt_ktime_hrtimer_control(rt_ktime_hrtimer_t timer, int cmd, void *arg); rt_err_t rt_ktime_hrtimer_control(rt_ktime_hrtimer_t timer, int cmd, void *arg);
rt_err_t rt_ktime_hrtimer_detach(rt_ktime_hrtimer_t timer); rt_err_t rt_ktime_hrtimer_detach(rt_ktime_hrtimer_t timer);
rt_inline void rt_ktime_hrtimer_keep_errno(rt_ktime_hrtimer_t timer, rt_err_t err)
{
RT_ASSERT(timer != RT_NULL);
timer->error = err;
}
/** /**
* @brief sleep by the cputimer cnt value * @brief sleep by the cputimer cnt value
* *

View File

@ -197,24 +197,6 @@ void rt_ktime_hrtimer_init(rt_ktime_hrtimer_t timer,
rt_sem_init(&(timer->sem), "hrtimer", 0, RT_IPC_FLAG_PRIO); rt_sem_init(&(timer->sem), "hrtimer", 0, RT_IPC_FLAG_PRIO);
} }
rt_err_t rt_ktime_hrtimer_delete(rt_ktime_hrtimer_t timer)
{
rt_base_t level;
/* parameter check */
RT_ASSERT(timer != RT_NULL);
level = rt_spin_lock_irqsave(&_spinlock);
_nowtimer = RT_NULL;
rt_list_remove(&timer->row);
timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; /* stop timer */
rt_spin_unlock_irqrestore(&_spinlock, level);
_set_next_timeout();
return RT_EOK;
}
rt_err_t rt_ktime_hrtimer_start(rt_ktime_hrtimer_t timer) rt_err_t rt_ktime_hrtimer_start(rt_ktime_hrtimer_t timer)
{ {
rt_list_t *timer_list; rt_list_t *timer_list;
@ -350,15 +332,22 @@ rt_err_t rt_ktime_hrtimer_detach(rt_ktime_hrtimer_t timer)
/* parameter check */ /* parameter check */
RT_ASSERT(timer != RT_NULL); RT_ASSERT(timer != RT_NULL);
level = rt_spin_lock_irqsave(&_spinlock); level = rt_spin_lock_irqsave(&_spinlock);
_nowtimer = RT_NULL;
rt_list_remove(&timer->row);
/* stop timer */ /* stop timer */
timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
rt_spin_unlock_irqrestore(&_spinlock, level); /* when interrupted */
if (timer->error == -RT_EINTR || timer->error == RT_EINTR)
_set_next_timeout(); {
_nowtimer = RT_NULL;
rt_list_remove(&timer->row);
rt_spin_unlock_irqrestore(&_spinlock, level);
_set_next_timeout();
}
else
{
rt_spin_unlock_irqrestore(&_spinlock, level);
}
rt_sem_detach(&(timer->sem)); rt_sem_detach(&(timer->sem));
return RT_EOK; return RT_EOK;
@ -369,6 +358,7 @@ rt_err_t rt_ktime_hrtimer_detach(rt_ktime_hrtimer_t timer)
rt_err_t rt_ktime_hrtimer_sleep(unsigned long cnt) rt_err_t rt_ktime_hrtimer_sleep(unsigned long cnt)
{ {
struct rt_ktime_hrtimer timer; struct rt_ktime_hrtimer timer;
rt_err_t err;
if (cnt == 0) if (cnt == 0)
return -RT_EINVAL; return -RT_EINVAL;
@ -377,7 +367,8 @@ rt_err_t rt_ktime_hrtimer_sleep(unsigned long cnt)
_sleep_timeout, &(timer.sem)); _sleep_timeout, &(timer.sem));
rt_ktime_hrtimer_start(&timer); /* reset the timeout of thread timer and start it */ rt_ktime_hrtimer_start(&timer); /* reset the timeout of thread timer and start it */
rt_sem_take_interruptible(&(timer.sem), RT_WAITING_FOREVER); err = rt_sem_take_interruptible(&(timer.sem), RT_WAITING_FOREVER);
rt_ktime_hrtimer_keep_errno(&timer, err);
rt_ktime_hrtimer_detach(&timer); rt_ktime_hrtimer_detach(&timer);
return RT_EOK; return RT_EOK;