summaryrefslogtreecommitdiff
path: root/src/scheduler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scheduler.c')
-rw-r--r--src/scheduler.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/scheduler.c b/src/scheduler.c
index 956d95d7cc..353fdad5cb 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -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,12 @@ 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 /* RT_USING_HOOK */
@@ -364,6 +371,8 @@ void rt_schedule(void)
_rt_scheduler_stack_check(to_thread);
#endif /* RT_USING_OVERFLOW_CHECK */
+ RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (current_thread));
+
rt_hw_context_switch((rt_ubase_t)&current_thread->sp,
(rt_ubase_t)&to_thread->sp, to_thread);
}
@@ -473,6 +482,8 @@ void rt_schedule(void)
{
extern void rt_thread_handle_sig(rt_bool_t clean_state);
+ RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (from_thread));
+
rt_hw_context_switch((rt_ubase_t)&from_thread->sp,
(rt_ubase_t)&to_thread->sp);
@@ -609,6 +620,8 @@ void rt_scheduler_do_irq_switch(void *context)
current_thread->cpus_lock_nest--;
current_thread->scheduler_lock_nest--;
+ RT_OBJECT_HOOK_CALL(rt_scheduler_switch_hook, (current_thread));
+
rt_hw_context_switch_interrupt(context, (rt_ubase_t)&current_thread->sp,
(rt_ubase_t)&to_thread->sp, to_thread);
}