mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
SMP: Use irq_cpu_locked() in sched_mergepending()
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
# include <nuttx/spinlock.h>
|
# include <nuttx/spinlock.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "irq/irq.h"
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -196,15 +197,16 @@ bool sched_mergepending(void)
|
|||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
int me;
|
||||||
|
|
||||||
/* Remove and process every TCB in the g_pendingtasks list.
|
/* Remove and process every TCB in the g_pendingtasks list.
|
||||||
*
|
*
|
||||||
* This function is only called in the context where locking is known to
|
* Do nothing if (1) pre-emption is still disabled (by any CPU), or (2) if
|
||||||
* disabled on one CPU. However, we must do nothing if pre-emption is
|
* some CPU other than this one is in a critical section.
|
||||||
* still locked because of actions of other CPUs.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!spin_islocked(&g_cpu_schedlock))
|
me = this_cpu();
|
||||||
|
if (!spin_islocked(&g_cpu_schedlock) && !irq_cpu_locked(me))
|
||||||
{
|
{
|
||||||
/* Find the CPU that is executing the lowest priority task */
|
/* Find the CPU that is executing the lowest priority task */
|
||||||
|
|
||||||
@@ -243,7 +245,7 @@ bool sched_mergepending(void)
|
|||||||
* Check if that happened.
|
* Check if that happened.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (spin_islocked(&g_cpu_schedlock))
|
if (spin_islocked(&g_cpu_schedlock) || irq_cpu_locked(me))
|
||||||
{
|
{
|
||||||
/* Yes.. then we may have incorrectly placed some TCBs in the
|
/* Yes.. then we may have incorrectly placed some TCBs in the
|
||||||
* g_readytorun list (unlikely, but possible). We will have to
|
* g_readytorun list (unlikely, but possible). We will have to
|
||||||
|
|||||||
Reference in New Issue
Block a user