nuttx/sched/task
Masayuki Ishikawa 35c8da34a8 sched: task: Fix nxtask_exit() for SMP
Summary:
- During Wi-Fi audio streaming test, I found a deadlock in nxtask_exit()
- Actually, nxtask_exit() was called and tried to enter critical section
- In enter_critical_section(), there is a deadlock avoidance logic
- However, if switched to a new rtcb with irqcount=0, the logic did not work
- Because the 2nd critical section was treated as if it were the 1st one
- Actually, it tried to run the deadlock avoidance logic
- But nxtask_exit() was called with critical section (i.e. IRQ already disabled)
- So the logic did not work as expected because up_irq_restore() did not enable the IRQ.
- This commit fixes this issue by incrementing irqcount before calling nxtask_terminate()
- Also it adjusts g_cpu_irqlock and g_cpu_lockset

Impact:
- Affects SMP only

Testing:
- Tested with spresense:wifi_smp (smp, ostest, nxplayer, telnetd)
- Tested with sabre-6quad:smp with QEMU (smp, ostest)
- Tested with maix-bit:smp with QEMU (smp, ostest)
- Tested with esp32-core:smp with QEMU (smp, ostest)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-10-10 13:01:01 -06:00
..
exit.c sched: Remove SCHED_EXIT_KILL_CHILDREN option 2020-06-15 07:17:43 -06:00
Make.defs Move gettid() implementation to /libs/libc/unistd 2020-09-22 19:40:56 -07:00
spawn.h Check return from nxsem_wait_initialize() 2020-03-29 20:11:10 +01:00
task_activate.c sched: Change the return type of nxtask_activate to void 2020-06-04 22:20:45 +01:00
task_atexit.c sched/task: Avoid the cast in atexit when CONFIG_SCHED_ONEXIT is defined 2020-06-05 13:29:22 +01:00
task_cancelpt.c sched: Consolidate the cancellation notification logic 2020-06-15 21:21:14 +01:00
task_create.c sched: Change tcb_s to task_tcb_s for nxtask_[un]init 2020-06-30 10:54:42 -06:00
task_delete.c sched: Consolidate the cancellation notification logic 2020-06-15 21:21:14 +01:00
task_execv.c task_execv.c:Fix style errors. 2020-03-08 07:28:04 -06:00
task_exit.c sched: task: Fix nxtask_exit() for SMP 2020-10-10 13:01:01 -06:00
task_exithook.c libc/stdio: Allocate file_struct dynamically 2020-09-11 17:58:17 +08:00
task_getgroup.c include/nuttx/sched.h: Make naming of all internal names consistent: 2020-05-09 14:19:08 -03:00
task_getpid.c Some cosmetic updates, mostly to spacing and comments. 2018-12-30 11:58:19 -06:00
task_init.c Revert "sched/sched/sched_releasetcb.c: Handle custom stack allocations." 2020-07-07 00:21:46 +01:00
task_onexit.c sched/task: Simplify atexit and onexit implementation 2020-06-05 13:29:22 +01:00
task_posixspawn.c include/nuttx/sched.h: Make naming of all internal names consistent: 2020-05-09 14:19:08 -03:00
task_prctl.c syscall/prctl: fix PR_SET_NAME failure if without <pid> arg 2020-07-01 21:52:18 -05:00
task_recover.c sched/sched/sched.h: Make naming of all internal names consistent: 2020-05-09 16:58:42 -03:00
task_reparent.c sched/: Make more naming consistent 2020-05-16 13:39:03 -03:00
task_restart.c sched/group: Change group_kill_children's argument from task_tcb_s to tcb_s 2020-06-15 07:09:51 -06:00
task_setcancelstate.c sched: Don't call nxnotify_cancellation in task_setcancelstate 2020-06-15 21:21:14 +01:00
task_setcanceltype.c Run codespell -w with the latest dictonary again 2020-02-23 22:27:46 +01:00
task_setup.c Make task_init() and task_activate() internal OS functions. 2020-05-25 23:54:45 +01:00
task_spawn.c sched/task/task_spawn.c: Fix duplicate task_spawn() 2020-06-01 16:40:06 +01:00
task_spawnparms.c include/nuttx/sched.h: Make naming of all internal names consistent: 2020-05-09 14:19:08 -03:00
task_start.c sched: nxtask_start should call entry point directly for kernel thread 2020-10-08 09:14:33 +02:00
task_starthook.c task_starthook.c:Fix style errors. 2020-03-08 07:28:04 -06:00
task_terminate.c sched/sched/sched.h: Make naming of all internal names consistent: 2020-05-09 16:58:42 -03:00
task_testcancel.c Run codespell -w with the latest dictonary again 2020-02-23 22:27:46 +01:00
task_vfork.c sched: Change the return type of nxtask_activate to void 2020-06-04 22:20:45 +01:00
task.h sched: Consolidate the cancellation notification logic 2020-06-15 21:21:14 +01:00