summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwdfk-prog <[email protected]>2025-09-21 09:43:26 +0800
committerR b b666 <[email protected]>2025-09-21 15:26:51 +0800
commit2d375b236c8c58d6fc75144ed18e7f484ec13b15 (patch)
tree6c7188b09edc970a23b1d9004bd61e8cb4ec58d6 /src
parent42458e0618d5e82b3e6c580f401e921a33d049dc (diff)
[kernel]fix scheduling exception caused by interrupt preemption in rt_schedule
Diffstat (limited to 'src')
-rw-r--r--src/scheduler_up.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 8099d3d9f3..2970202dbf 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -32,6 +32,7 @@
* 2023-10-17 ChuShicheng Modify the timing of clearing RT_THREAD_STAT_YIELD flag bits
* 2025-08-04 Pillar Add rt_scheduler_critical_switch_flag
* 2025-08-20 RyanCW rt_scheduler_lock_nest use atomic operations
+ * 2025-09-20 wdfk_prog fix scheduling exception caused by interrupt preemption in rt_schedule
*/
#define __RT_IPC_SOURCE__
@@ -283,12 +284,14 @@ void rt_schedule(void)
rt_base_t level;
struct rt_thread *to_thread;
struct rt_thread *from_thread;
- /* using local variable to avoid unecessary function call */
- struct rt_thread *curr_thread = rt_thread_self();
+ struct rt_thread *curr_thread;
/* disable interrupt */
level = rt_hw_interrupt_disable();
+ /* using local variable to avoid unnecessary function call */
+ curr_thread = rt_thread_self();
+
/* check the scheduler is enabled or not */
if (rt_scheduler_lock_nest == 0)
{