Skip to content

Commit f23fb7e

Browse files
GUIDINGLIxiaoxiang781216
authored andcommitted
sched: disable interrupt in non-SMP case
For the nested interrupt, one thing should decleared: We are in ISR context, but no meaning we are disabled the interrupts. Signed-off-by: ligd <[email protected]>
1 parent 35fcd93 commit f23fb7e

File tree

4 files changed

+81
-255
lines changed

4 files changed

+81
-255
lines changed

sched/sched/sched.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,8 @@ int nxsched_reprioritize(FAR struct tcb_s *tcb, int sched_priority);
340340
/* Support for tickless operation */
341341

342342
#ifdef CONFIG_SCHED_TICKLESS
343-
clock_t nxsched_cancel_timer(void);
344-
void nxsched_resume_timer(void);
345343
void nxsched_reassess_timer(void);
346344
#else
347-
# define nxsched_cancel_timer() (0)
348-
# define nxsched_resume_timer()
349345
# define nxsched_reassess_timer()
350346
#endif
351347

sched/sched/sched_processtimer.c

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ static inline void nxsched_cpu_scheduler(int cpu)
109109
#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC)
110110
static inline void nxsched_process_scheduler(void)
111111
{
112-
#ifdef CONFIG_SMP
113112
irqstate_t flags;
114113
int i;
115114

116-
/* If we are running on a single CPU architecture, then we know interrupts
117-
* are disabled and there is no need to explicitly call
118-
* enter_critical_section(). However, in the SMP case,
115+
/* Single CPU case:
116+
* For nested interrupts, higher IRQs may interrupt nxsched_cpu_scheduler()
117+
* but nxsched_cpu_scheduler() requires that interrupts be disabled.
118+
* We are in ISR context, no meaning we are disabled the interrupts.
119+
*
120+
* SMP case:
119121
* enter_critical_section() does much more than just disable interrupts on
120122
* the local CPU; it also manages spinlocks to assure the stability of the
121123
* TCB that we are manipulating.
@@ -131,53 +133,11 @@ static inline void nxsched_process_scheduler(void)
131133
}
132134

133135
leave_critical_section(flags);
134-
135-
#else
136-
/* Perform scheduler operations on the single CPUs */
137-
138-
nxsched_cpu_scheduler(0);
139-
#endif
140136
}
141137
#else
142138
# define nxsched_process_scheduler()
143139
#endif
144140

145-
/****************************************************************************
146-
* Name: nxsched_process_wdtimer
147-
*
148-
* Description:
149-
* Wdog timer process, should with critical_section when SMP mode.
150-
*
151-
* Input Parameters:
152-
* None
153-
*
154-
* Returned Value:
155-
* None
156-
*
157-
****************************************************************************/
158-
159-
#ifdef CONFIG_SMP
160-
static inline void nxsched_process_wdtimer(clock_t ticks)
161-
{
162-
irqstate_t flags;
163-
164-
/* We are in an interrupt handler and, as a consequence, interrupts are
165-
* disabled. But in the SMP case, interrupts MAY be disabled only on
166-
* the local CPU since most architectures do not permit disabling
167-
* interrupts on other CPUS.
168-
*
169-
* Hence, we must follow rules for critical sections even here in the
170-
* SMP case.
171-
*/
172-
173-
flags = enter_critical_section();
174-
wd_timer(ticks);
175-
leave_critical_section(flags);
176-
}
177-
#else
178-
# define nxsched_process_wdtimer(ticks) wd_timer(ticks)
179-
#endif
180-
181141
/****************************************************************************
182142
* Public Functions
183143
****************************************************************************/
@@ -236,7 +196,7 @@ void nxsched_process_timer(void)
236196

237197
/* Process watchdogs */
238198

239-
nxsched_process_wdtimer(clock_systime_ticks());
199+
wd_timer(clock_systime_ticks());
240200

241201
#ifdef CONFIG_SYSTEMTICK_HOOK
242202
/* Call out to a user-provided function in order to perform board-specific,

0 commit comments

Comments
 (0)