SMP: Introduce a new global IRQ clearing logic and tasklist protection.
The previous implementation of clearing global IRQ in sched_addreadytorun()
and sched_removereadytorun() was done too early. As a result, nxsem_post()
would have a chance to enter the critical section even nxsem_wait() is
still not in blocked state. This patch moves clearing global IRQ controls
from sched_addreadytorun() and sched_removereadytorun() to sched_resumescheduler()
to ensure that nxsem_post() can enter the critical section correctly.
For this change, sched_resumescheduler.c is always necessary for SMP configuration.
In addition, by this change, task_exit() had to be modified so that it calls
sched_resumescheduler() because it calls sched_removescheduler() inside the
function, otherwise it will cause a deadlock.
However, I encountered another DEBUGASSERT() in sched_cpu_select() during
HTTP streaming aging test on lc823450-xgevk. Actually sched_cpu_select()
accesses the g_assignedtasks which might be changed by another CPU. Similarly,
other tasklists might be modified simultaneously if both CPUs are executing
scheduling logic. To avoid this, I introduced tasklist protetion APIs.
With these changes, SMP kernel stability has been much improved.
Signed-off-by:
Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Showing
- include/nuttx/sched.h 1 addition, 1 deletioninclude/nuttx/sched.h
- sched/sched/Make.defs 6 additions, 0 deletionssched/sched/Make.defs
- sched/sched/sched.h 8 additions, 0 deletionssched/sched/sched.h
- sched/sched/sched_addblocked.c 12 additions, 0 deletionssched/sched/sched_addblocked.c
- sched/sched/sched_addreadytorun.c 10 additions, 4 deletionssched/sched/sched_addreadytorun.c
- sched/sched/sched_mergepending.c 12 additions, 3 deletionssched/sched/sched_mergepending.c
- sched/sched/sched_mergeprioritized.c 17 additions, 2 deletionssched/sched/sched_mergeprioritized.c
- sched/sched/sched_removereadytorun.c 12 additions, 4 deletionssched/sched/sched_removereadytorun.c
- sched/sched/sched_resumescheduler.c 40 additions, 2 deletionssched/sched/sched_resumescheduler.c
- sched/sched/sched_tasklistlock.c 133 additions, 0 deletionssched/sched/sched_tasklistlock.c
- sched/task/task_exit.c 8 additions, 0 deletionssched/task/task_exit.c
Loading
Please register or sign in to comment