mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 11:16:47 +00:00
设定每次执行的定时任务的最大数量
This commit is contained in:
parent
f4891cc8a3
commit
ee0b5ed3fd
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
struct timer_func_list_t timer_func_head;
|
struct timer_func_list_t timer_func_head;
|
||||||
|
|
||||||
|
// 定时器循环阈值,每次最大执行10个定时器任务
|
||||||
|
#define TIMER_RUN_CYCLE_THRESHOLD 10
|
||||||
|
|
||||||
void test_timer()
|
void test_timer()
|
||||||
{
|
{
|
||||||
printk_color(ORANGE, BLACK, "(test_timer)");
|
printk_color(ORANGE, BLACK, "(test_timer)");
|
||||||
@ -29,17 +32,20 @@ void do_timer_softirq(void *data)
|
|||||||
{
|
{
|
||||||
|
|
||||||
struct timer_func_list_t *tmp = container_of(list_next(&timer_func_head.list), struct timer_func_list_t, list);
|
struct timer_func_list_t *tmp = container_of(list_next(&timer_func_head.list), struct timer_func_list_t, list);
|
||||||
|
int cycle_count = 0;
|
||||||
while ((!list_empty(&timer_func_head.list)) && (tmp->expire_jiffies <= timer_jiffies))
|
while ((!list_empty(&timer_func_head.list)) && (tmp->expire_jiffies <= timer_jiffies))
|
||||||
{
|
{
|
||||||
|
|
||||||
timer_func_del(tmp);
|
timer_func_del(tmp);
|
||||||
tmp->func(tmp->data);
|
tmp->func(tmp->data);
|
||||||
kfree(tmp);
|
kfree(tmp);
|
||||||
tmp = container_of(list_next(&timer_func_head.list), struct timer_func_list_t, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
++cycle_count;
|
||||||
|
// 当前定时器达到阈值
|
||||||
|
if(cycle_count == TIMER_RUN_CYCLE_THRESHOLD)
|
||||||
|
break;
|
||||||
|
tmp = container_of(list_next(&timer_func_head.list), struct timer_func_list_t, list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
uint64_t volatile timer_jiffies = 0; // 系统时钟计数
|
uint64_t volatile timer_jiffies = 0; // 系统时钟计数
|
||||||
|
|
||||||
// 计算接下来n毫秒对应的系统时间片
|
// 计算接下来n毫秒对应的系统时间片
|
||||||
#define cal_next_n_ms_jiffies(expire_ms) (timer_jiffies + expire_ms / 5 + (expire_ms % HPET0_INTERVAL ? 1 : 0))
|
#define cal_next_n_ms_jiffies(expire_ms) (timer_jiffies + expire_ms / 5 + ((expire_ms % HPET0_INTERVAL) ? 1 : 0))
|
||||||
|
|
||||||
void timer_init();
|
void timer_init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user