mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
Revert "SMP: Fix a error introduced in 36b676eea6 and fully decouple disabling of pre-emption from critical sections."
This reverts commit 9aedf1bdec.
This commit is contained in:
@@ -507,6 +507,36 @@ void leave_critical_section(irqstate_t flags)
|
|||||||
rtcb->irqcount = 0;
|
rtcb->irqcount = 0;
|
||||||
spin_clrbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock,
|
spin_clrbit(&g_cpu_irqset, cpu, &g_cpu_irqsetlock,
|
||||||
&g_cpu_irqlock);
|
&g_cpu_irqlock);
|
||||||
|
|
||||||
|
/* Have all CPUs released the lock? */
|
||||||
|
|
||||||
|
if (!spin_islocked(&g_cpu_irqlock))
|
||||||
|
{
|
||||||
|
/* Check if there are pending tasks and that pre-emption
|
||||||
|
* is also enabled.
|
||||||
|
*
|
||||||
|
* REVISIT: Is there an issue here? up_release_pending()
|
||||||
|
* must be called from within a critical section but here
|
||||||
|
* we have just left the critical section. At least we
|
||||||
|
* still have interrupts disabled on this CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (g_pendingtasks.head != NULL &&
|
||||||
|
!spin_islocked(&g_cpu_schedlock))
|
||||||
|
{
|
||||||
|
/* Release any ready-to-run tasks that have collected
|
||||||
|
* in g_pendingtasks if the scheduler is not locked.
|
||||||
|
*
|
||||||
|
* NOTE: This operation has a very high likelihood of
|
||||||
|
* causing this task to be switched out!
|
||||||
|
*
|
||||||
|
* REVISIT: Should this not be done while we are in the
|
||||||
|
* critical section.
|
||||||
|
*/
|
||||||
|
|
||||||
|
up_release_pending();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,8 +102,7 @@ int sched_unlock(void)
|
|||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/* The lockcount has decremented to zero and we need to perform
|
/* The lockcount has decremented to zero and we need to perform
|
||||||
* release our hold on the lock. Pre-emption may still be locked
|
* release our hold on the lock.
|
||||||
* from other CPUs.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(g_cpu_schedlock == SP_LOCKED &&
|
DEBUGASSERT(g_cpu_schedlock == SP_LOCKED &&
|
||||||
@@ -119,12 +118,13 @@ int sched_unlock(void)
|
|||||||
*
|
*
|
||||||
* NOTE: This operation has a very high likelihood of causing
|
* NOTE: This operation has a very high likelihood of causing
|
||||||
* this task to be switched out!
|
* this task to be switched out!
|
||||||
*
|
|
||||||
* NOTE: In SMP mode, pre-emption may still be locked due to
|
|
||||||
* operations on other CPUs.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
if (!spin_islocked(&g_cpu_schedlock) && g_pendingtasks.head != NULL)
|
||||||
|
#else
|
||||||
if (g_pendingtasks.head != NULL)
|
if (g_pendingtasks.head != NULL)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
up_release_pending();
|
up_release_pending();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user