[timer]add all soft timer config (#9048)

* add all soft timer

* update wq

* add timer test

* shield LOG_D
This commit is contained in:
zms123456
2024-06-20 04:20:38 +08:00
committed by GitHub
parent 6bd6317f77
commit 59193dfeeb
5 changed files with 534 additions and 340 deletions
+12 -23
View File
@@ -94,7 +94,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
struct rt_work *work, rt_tick_t ticks)
{
rt_base_t level;
rt_err_t err;
rt_err_t err = RT_EOK;
level = rt_spin_lock_irqsave(&(queue->spinlock));
@@ -113,13 +113,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
{
/* resume work thread, and do a re-schedule if succeed */
rt_thread_resume(queue->work_thread);
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
else
{
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
return RT_EOK;
}
else if (ticks < RT_TICK_MAX / 2)
{
@@ -139,12 +133,14 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
rt_list_insert_after(queue->delayed_list.prev, &(work->list));
err = rt_timer_start(&(work->timer));
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return err;
}
else
{
err = - RT_ERROR;
}
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return -RT_ERROR;
return err;
}
static rt_err_t _workqueue_cancel_work(struct rt_workqueue *queue, struct rt_work *work)
@@ -160,14 +156,14 @@ static rt_err_t _workqueue_cancel_work(struct rt_workqueue *queue, struct rt_wor
{
if ((err = rt_timer_stop(&(work->timer))) != RT_EOK)
{
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return err;
goto exit;
}
rt_timer_detach(&(work->timer));
work->flags &= ~RT_WORK_STATE_SUBMITTING;
}
err = queue->work_current != work ? RT_EOK : -RT_EBUSY;
work->workqueue = RT_NULL;
exit:
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return err;
}
@@ -200,12 +196,9 @@ static void _delayed_work_timeout_handler(void *parameter)
{
/* resume work thread, and do a re-schedule if succeed */
rt_thread_resume(queue->work_thread);
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
else
{
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
/**
@@ -358,13 +351,9 @@ rt_err_t rt_workqueue_urgent_work(struct rt_workqueue *queue, struct rt_work *wo
{
/* resume work thread, and do a re-schedule if succeed */
rt_thread_resume(queue->work_thread);
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
else
{
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
}
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return RT_EOK;
}
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -579,14 +579,13 @@ struct rt_object_information
*/
#define RT_TIMER_FLAG_DEACTIVATED 0x0 /**< timer is deactive */
#define RT_TIMER_FLAG_ACTIVATED 0x1 /**< timer is active */
#define RT_TIMER_FLAG_PROCESSING 0x2 /**< timer's timeout fuction is processing */
#define RT_TIMER_FLAG_ONE_SHOT 0x0 /**< one shot timer */
#define RT_TIMER_FLAG_PERIODIC 0x4 /**< periodic timer */
#define RT_TIMER_FLAG_PERIODIC 0x2 /**< periodic timer */
#define RT_TIMER_FLAG_HARD_TIMER 0x0 /**< hard timer,the timer's callback function will be called in tick isr. */
#define RT_TIMER_FLAG_SOFT_TIMER 0x8 /**< soft timer,the timer's callback function will be called in timer thread. */
#define RT_TIMER_FLAG_SOFT_TIMER 0x4 /**< soft timer,the timer's callback function will be called in timer thread. */
#define RT_TIMER_FLAG_THREAD_TIMER \
(0x10 | RT_TIMER_FLAG_HARD_TIMER) /**< thread timer that cooperates with scheduler directly */
(0x8 | RT_TIMER_FLAG_HARD_TIMER) /**< thread timer that cooperates with scheduler directly */
#define RT_TIMER_CTRL_SET_TIME 0x0 /**< set timer control command */
#define RT_TIMER_CTRL_GET_TIME 0x1 /**< get timer control command */
+4
View File
@@ -176,6 +176,10 @@ if RT_USING_TIMER_SOFT
int "The stack size of timer thread"
default 2048 if ARCH_CPU_64BIT
default 512
config RT_USING_TIMER_ALL_SOFT
bool "Set all timer as soft timer"
default n
endif
config RT_USING_CPU_USAGE_TRACER
+44 -48
View File
File diff suppressed because it is too large Load Diff