This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 8940646  sched: sched: Don't call sched_lock()/unlock() in 
nx_waitid()/waitpid() for SMP
8940646 is described below

commit 89406462cc710a3e9c7e16af1d97b026f1177bdd
Author: Masayuki Ishikawa <[email protected]>
AuthorDate: Tue Jan 5 09:35:19 2021 +0900

    sched: sched: Don't call sched_lock()/unlock() in nx_waitid()/waitpid() for 
SMP
    
    Summary:
    - Calling sched_lock()/unlock() is unnecessary for SMP
      because we've been using the critical section API
    
    Impact:
    - SMP only
    
    Testing:
    - Tested with smp and ostest with the following configurations
    - sabre-6quad:smp (QEMU, dev board)
    - spresense:smp, spresense:wifi_smp
    - sim:smp, sim:ostest
    - maix-bit:smp (QEMU)
    - esp32-devkitc:smp (QEMU)
    - lc823450-xgevk:rndis
    
    Signed-off-by: Masayuki Ishikawa <[email protected]>
---
 sched/sched/sched_waitid.c  |  7 ++++---
 sched/sched/sched_waitpid.c | 14 ++++++++------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c
index 3b119d3..0c8c895 100644
--- a/sched/sched/sched_waitid.c
+++ b/sched/sched/sched_waitid.c
@@ -152,11 +152,11 @@ int nx_waitid(int idtype, id_t id, FAR siginfo_t *info, 
int options)
 
 #ifdef CONFIG_SMP
   irqstate_t flags = enter_critical_section();
-#endif
-
+#else
   /* Disable pre-emption so that nothing changes while the loop executes */
 
   sched_lock();
+#endif
 
   /* Verify that this task actually has children and that the requested
    * TCB is actually a child of this task.
@@ -417,10 +417,11 @@ int nx_waitid(int idtype, id_t id, FAR siginfo_t *info, 
int options)
     }
 
 errout:
-  sched_unlock();
 
 #ifdef CONFIG_SMP
   leave_critical_section(flags);
+#else
+  sched_unlock();
 #endif
 
   return ret;
diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c
index 40534b6..d787ca0 100644
--- a/sched/sched/sched_waitpid.c
+++ b/sched/sched/sched_waitpid.c
@@ -78,11 +78,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
 
 #ifdef CONFIG_SMP
   irqstate_t flags = enter_critical_section();
-#endif
-
+#else
   /* Disable pre-emption so that nothing changes in the following tests */
 
   sched_lock();
+#endif
 
   /* Get the TCB corresponding to this PID */
 
@@ -169,10 +169,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
   ret = pid;
 
 errout:
-  sched_unlock();
 
 #ifdef CONFIG_SMP
   leave_critical_section(flags);
+#else
+  sched_unlock();
 #endif
 
   return ret;
@@ -217,11 +218,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
 
 #ifdef CONFIG_SMP
   irqstate_t flags = enter_critical_section();
-#endif
-
+#else
   /* Disable pre-emption so that nothing changes while the loop executes */
 
   sched_lock();
+#endif
 
   /* Verify that this task actually has children and that the requested PID
    * is actually a child of this task.
@@ -464,10 +465,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options)
   ret = pid;
 
 errout:
-  sched_unlock();
 
 #ifdef CONFIG_SMP
   leave_critical_section(flags);
+#else
+  sched_unlock();
 #endif
 
   return ret;

Reply via email to