Skip to content

Commit 2d375b2

Browse files
wdfk-progRbb666
authored andcommitted
[kernel]fix scheduling exception caused by interrupt preemption in rt_schedule
1 parent 42458e0 commit 2d375b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/scheduler_up.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* 2023-10-17 ChuShicheng Modify the timing of clearing RT_THREAD_STAT_YIELD flag bits
3333
* 2025-08-04 Pillar Add rt_scheduler_critical_switch_flag
3434
* 2025-08-20 RyanCW rt_scheduler_lock_nest use atomic operations
35+
* 2025-09-20 wdfk_prog fix scheduling exception caused by interrupt preemption in rt_schedule
3536
*/
3637

3738
#define __RT_IPC_SOURCE__
@@ -283,12 +284,14 @@ void rt_schedule(void)
283284
rt_base_t level;
284285
struct rt_thread *to_thread;
285286
struct rt_thread *from_thread;
286-
/* using local variable to avoid unecessary function call */
287-
struct rt_thread *curr_thread = rt_thread_self();
287+
struct rt_thread *curr_thread;
288288

289289
/* disable interrupt */
290290
level = rt_hw_interrupt_disable();
291291

292+
/* using local variable to avoid unnecessary function call */
293+
curr_thread = rt_thread_self();
294+
292295
/* check the scheduler is enabled or not */
293296
if (rt_scheduler_lock_nest == 0)
294297
{

0 commit comments

Comments
 (0)