|
|
@@ -49,6 +49,7 @@ rt_uint8_t rt_current_priority;
|
|
|
|
|
|
#ifdef RT_USING_HOOK
|
|
|
static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to);
|
|
|
+static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
|
|
|
|
|
|
/**
|
|
|
* @addtogroup Hook
|
|
|
@@ -68,6 +69,11 @@ rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to))
|
|
|
rt_scheduler_hook = hook;
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid))
|
|
|
+{
|
|
|
+ rt_scheduler_switch_hook = hook;
|
|
|
+}
|
|
|
/**@}*/
|
|
|
#endif
|
|
|
|
|
|
@@ -372,7 +378,7 @@ void rt_schedule(void)
|
|
|
#ifdef RT_USING_OVERFLOW_CHECK
|
|
|
_rt_scheduler_stack_check(to_thread);
|
|
|
#endif
|
|
|
-
|
|
|
+ RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (current_thread));
|
|
|
rt_hw_context_switch((rt_ubase_t)¤t_thread->sp,
|
|
|
(rt_ubase_t)&to_thread->sp, to_thread);
|
|
|
}
|
|
|
@@ -478,6 +484,7 @@ void rt_schedule(void)
|
|
|
_rt_scheduler_stack_check(to_thread);
|
|
|
#endif
|
|
|
|
|
|
+ RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (from_thread));
|
|
|
if (rt_interrupt_nest == 0)
|
|
|
{
|
|
|
extern void rt_thread_handle_sig(rt_bool_t clean_state);
|