You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "evolution124 (via GitHub)" <gi...@apache.org> on 2026/08/04 10:01:41 UTC

[I] [BUG] normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp) [nuttx]

evolution124 opened a new issue, #19680:
URL: https://github.com/apache/nuttx/issues/19680

   ### Description / Steps to reproduce the issue
   
   on latest nuttx, configure with nsh64 & smp & and CONFIG_SMP_NCPU is 2.
   The issue is after adjust task's affinity, the task may became an orphan task which will never be scheduled to run any more.
   
   ### 1. The setup are like bellow:
   1.1) M is main task
   1.2) T0, T1 are task0 and task1
   2.3) C0, C1 are CPU0 and CPU1
   
   ### 2. The issue produced as bellow.
   2.1) main task create two task, t0 and t1. 
       **M task** 
           **-> pthread_create(t0, t0_task_entry ....)**
           **-> pthread_create(t1, t1_task_entry ....)**
   
   2.2) sometimes, t0 and t1 may scheduled to CPU1
        **t0 running on CPU1**
                **-> t0  set affinity to CPU0 (by sched_setaffinity)**
        **t1 is pending on CPU1 because t0 is running.**
   
   2.3)  schedule tick came, t0 goto g_readytorun
           **t0 switching out to g_readytorun tasklist(the affinity is CPU0, not CPU1, so in SMP goto g_readylist)**
           **t1 switching in, set t1's affinity to CPU1 (by sched_setaffinity)**
   
   2.4) because prevsiously all the tasks are created on CPU1, so CPU0 only have idle task, which do not have TCB_FLAG_SCHED_RR  flag, then t0 in g_readytorun task list became an orphan task(no schedule running). Code as bellow.
   
   ```
   //./nuttxspace/nuttx/sched/sched/sched_processtick.c
   
   static inline void nxsched_cpu_scheduler(int cpu)
   {
     FAR struct tcb_s *rtcb = current_task(cpu);
     ...
     //idle task won't branch to run nxsched_process_roundrobin(...)
     if ((rtcb->flags & TCB_FLAG_POLICY_MASK) == TCB_FLAG_SCHED_RR) 
       {
           //this will not be called because the rtcb is idle task which does not have TCB_FLAG_SCHED_RR flag.
           **nxsched_process_roundrobin(rtcb, 1, false);
       }
   ```
           
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   ### On which OS does this issue occur?
   
   [OS: Linux]
   
   ### What is the version of your OS?
   
   Ubuntu 22.04.4 LTS
   
   ### NuttX Version
   
   375462322eeb6d2da57e6dff84c747a56bfa2eef (origin/master)
   
   ### Issue Architecture
   
   [Arch: risc-v]
   
   ### Issue Area
   
   [Area: OS Components], [Area: Kernel]
   
   ### Host information
   
   qemu to run the rv64
   qemu-system-riscv64 --version
   QEMU emulator version 10.0.0
   Copyright (c) 2003-2025 Fabrice Bellard and the QEMU Project developers
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp) [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on issue #19680:
URL: https://github.com/apache/nuttx/issues/19680#issuecomment-5183394603

   @xiaoxiang781216 did you or your team already found this issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 closed issue #19680: [BUG]  normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp)
URL: https://github.com/apache/nuttx/issues/19680


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on issue #19680:
URL: https://github.com/apache/nuttx/issues/19680#issuecomment-5186648448

   > [@xiaoxiang781216](https://github.com/xiaoxiang781216) did you or your team already found this issue?
   
   @hujun260 could you repo this problem?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] normal task became an orphan task when enable SMP after adjust task affinity (nsh64_smp) [nuttx]

Posted by "hujun260 (via GitHub)" <gi...@apache.org>.
hujun260 commented on issue #19680:
URL: https://github.com/apache/nuttx/issues/19680#issuecomment-5187969784

   > > [@xiaoxiang781216](https://github.com/xiaoxiang781216) did you or your team already found this issue?
   > 
   > [@hujun260](https://github.com/hujun260) could you repo this problem?
   
   https://github.com/apache/nuttx/pull/19687


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org