Skip to content

Commit ce119f5

Browse files
nashifdanieldegrasse
authored andcommitted
tracing: do not mark thread as switched_out in case of no reschedule
If z_get_next_switch_handle determines no reschdule is needed, do not mark thread as switched_out in set_curent() where new and old thread are the same. See #88596 for more details. Signed-off-by: Anas Nashif <[email protected]>
1 parent 7f282f7 commit ce119f5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/sched.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,12 @@ struct k_thread *z_swap_next_thread(void)
820820
/* Just a wrapper around z_current_thread_set(xxx) with tracing */
821821
static inline void set_current(struct k_thread *new_thread)
822822
{
823-
z_thread_mark_switched_out();
823+
/* If the new thread is the same as the current thread, we
824+
* don't need to do anything.
825+
*/
826+
if (IS_ENABLED(CONFIG_INSTRUMENT_THREAD_SWITCHING) && new_thread != _current) {
827+
z_thread_mark_switched_out();
828+
}
824829
z_current_thread_set(new_thread);
825830
}
826831

0 commit comments

Comments
 (0)