Skip to content

[proposal] rt_timer_check 长时间关闭中断,影响系统实时性, 或许可以优化 #8056

Description

@a1012112796

目前 rt_timer_check 为了确保 timer list 的一致性,全程关闭中断 (时间长达数十us, 且理论上会随定时器数量的增加而变大),影响了系统的实时性,或许可以通过算法优化,尽可能减少中断关闭的时间。

此问题是社区微信群里的大佬提出的,个人认为确实值得优化,但暂时没想到太好的方案, mark 一下。

level = rt_hw_interrupt_disable();

一些 tips:

  • 群里大佬提到了在执行 hook 的时候暂时恢复中断来减少关闭中断的时间,但我感觉不太可。。。示例如下:
@@ -685,9 +685,16 @@ void rt_timer_check(void)
             }
             /* add timer to temporary list  */
             rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));
+
+            /* enable interrupt */
+            rt_hw_interrupt_enable(level);
+
             /* call timeout function */
             t->timeout_func(t->parameter);
 
+            /* disable interrupt */
+            level = rt_hw_interrupt_disable();
+
             /* re-get tick */
             current_tick = rt_tick_get();
  • 个人对别的实时操作系统了解不多,好奇 free-rtos 等其它实时操作系统是如何做的,是否有更好的方案.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalproposal for future version

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions