Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-04 Thread via GitHub


xiaoxiang781216 merged PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168


-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-03 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1381819264


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,108 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((FAR struct thread_parmeter_s *)parameter)->result;
+  FAR spinlock_t *lock = ((FAR struct thread_parmeter_s *)parameter)->lock;
+
+  for (int i = 0; i < TEST_NUM; i++)

Review Comment:
   Done.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-03 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1381798070


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,108 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((FAR struct thread_parmeter_s *)parameter)->result;
+  FAR spinlock_t *lock = ((FAR struct thread_parmeter_s *)parameter)->lock;
+
+  for (int i = 0; i < TEST_NUM; i++)

Review Comment:
   `int i` move out of for loop



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-03 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1381792660


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,107 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((struct thread_parmeter_s *)parameter)->result;
+  FAR spinlock_t *lock = ((struct thread_parmeter_s *)parameter)->lock;
+
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock(lock);
+  (*result)++;
+  spin_unlock(lock);
+}
+
+  return NULL;
+}
+
+/
+ * Public Functions
+ /
+
+void main(void)
+{
+  spinlock_t lock = SP_UNLOCKED;
+  int result = 0;
+  pthread_t thread[THREAD_NUM];
+  struct thread_parmeter_s para;
+  clock_t start, end;

Review Comment:
   Done. Please review.
   Thank you a lot!!!



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-02 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1381131242


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,107 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((struct thread_parmeter_s *)parameter)->result;
+  FAR spinlock_t *lock = ((struct thread_parmeter_s *)parameter)->lock;
+
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock(lock);
+  (*result)++;
+  spin_unlock(lock);
+}
+
+  return NULL;
+}
+
+/
+ * Public Functions
+ /
+
+void main(void)
+{
+  spinlock_t lock = SP_UNLOCKED;
+  int result = 0;
+  pthread_t thread[THREAD_NUM];
+  struct thread_parmeter_s para;
+  clock_t start, end;
+
+  int status;
+  int i;
+
+  para.result = 
+  para.lock = 
+
+  start = perf_gettime();
+  for (i = 0; i < THREAD_NUM; ++i)
+{
+  status = pthread_create([i], NULL,
+thread_spinlock, );

Review Comment:
   ```suggestion
 thread_spinlock, );
   ```



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,107 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ 

Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-02 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1380193481


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,106 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((FAR struct thread_parmeter_s *)parameter)->result;
+  spinlock_t *lock = ((FAR struct thread_parmeter_s *)parameter)->lock;
+
+  for (FAR int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock(lock);
+  (*result)++;
+  spin_unlock(lock);
+}
+
+  return NULL;
+}
+
+/
+ * Public Functions
+ /
+
+void main(void)
+{
+  FAR spinlock_t lock = SP_UNLOCKED;
+  FAR int result = 0;
+  FAR pthread_t thread[THREAD_NUM];
+  FAR struct thread_parmeter_s para;
+
+  FAR int status;
+  FAR int i;
+
+  para.result = 
+  para.lock = 
+
+  FAR clock_t start = perf_gettime();
+  for (i = 0; i < THREAD_NUM; ++i)
+{
+  status = pthread_create([i], NULL,
+thread_spinlock, );
+  if (status != 0)
+{
+  printf("spinlock_test: ERROR pthread_create failed, status=%d\n",
+ status);
+  ASSERT(false);
+}
+}
+
+  for (i = 0; i < THREAD_NUM; ++i)
+{
+  pthread_join(thread[i], NULL);
+}
+
+  FAR clock_t end = perf_gettime();

Review Comment:
   Done.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-02 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1380185473


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+
+static FAR void *thread_spinlock(FAR void *parameter)

Review Comment:
   > pointer in common code need add FAR, except the arch/chip/board specific 
code could remove FAR if they don't distinguish near and far.
   
   Got it. Thanks your answer.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378827947


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,106 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Type
+ /
+
+struct thread_parmeter_s
+{
+  FAR int *result;
+  FAR spinlock_t *lock;
+};
+
+/
+ * Private Functions
+ /
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  FAR int *result = ((FAR struct thread_parmeter_s *)parameter)->result;
+  spinlock_t *lock = ((FAR struct thread_parmeter_s *)parameter)->lock;
+
+  for (FAR int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock(lock);
+  (*result)++;
+  spin_unlock(lock);
+}
+
+  return NULL;
+}
+
+/
+ * Public Functions
+ /
+
+void main(void)
+{
+  FAR spinlock_t lock = SP_UNLOCKED;
+  FAR int result = 0;
+  FAR pthread_t thread[THREAD_NUM];
+  FAR struct thread_parmeter_s para;
+
+  FAR int status;
+  FAR int i;
+
+  para.result = 
+  para.lock = 
+
+  FAR clock_t start = perf_gettime();
+  for (i = 0; i < THREAD_NUM; ++i)
+{
+  status = pthread_create([i], NULL,
+thread_spinlock, );
+  if (status != 0)
+{
+  printf("spinlock_test: ERROR pthread_create failed, status=%d\n",
+ status);
+  ASSERT(false);
+}
+}
+
+  for (i = 0; i < THREAD_NUM; ++i)
+{
+  pthread_join(thread[i], NULL);
+}
+
+  FAR clock_t end = perf_gettime();

Review Comment:
   Move `clock_t end` to the begin 



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,106 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ 

Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378759746


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+
+static FAR void *thread_spinlock(FAR void *parameter)

Review Comment:
   pointer in common code need add FAR, except the arch/chip/board specific 
code could remove FAR if they don't distinguish near and far.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378630098


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+
+static FAR void *thread_spinlock(FAR void *parameter)
+{
+  int *g_result = ((struct thread_parmeter_s *)parameter)->g_result;
+  spinlock_t *lock = ((struct thread_parmeter_s *)parameter)->lock;
+
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock(lock);
+  (*g_result)++;
+  spin_unlock(lock);
+}
+
+  return NULL;
+}
+
+/
+ * Public Functions
+ /
+
+void main(void)
+{
+  spinlock_t lock = SP_UNLOCKED;
+  int g_result = 0;
+  pthread_t g_thread[THREAD_NUM];

Review Comment:
   Done.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378627448


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+

Review Comment:
   Is this called banner?
   ```
   /
* Private Functions

/
```
   If yes, I already add it to code.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378627448


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+

Review Comment:
   Is this called banner?
   ```
   /
* Private Functions

/
```
   



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-11-01 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378625824


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;
+  spinlock_t *lock;
+};
+
+static FAR void *thread_spinlock(FAR void *parameter)

Review Comment:
   Im not sure every type is needed to add FAR or not.
   If there is any mistake, please tell me.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1378304129


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data

Review Comment:
   Type



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+struct thread_parmeter_s
+{
+  int *g_result;

Review Comment:
   ```suggestion
 int *result;
   ```



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,102 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+

Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377445193


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   > So this test will be enabled for FLAT build only?
   
   Yes. I modified Kconfig and set this feature depend on BUILD_FLAT.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377453282


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;

Review Comment:
   Done.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377445193


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   > So this test will be enabled for FLAT build only?
   
   Yes.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377436157


##
benchmarks/spinlock_bench/Makefile:
##
@@ -0,0 +1,52 @@
+
+# apps/benchmarks/coremark/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+
+include $(APPDIR)/Make.defs
+
+# spinlock_bench application
+
+
+# Targets
+
+
+clean::

Review Comment:
   After checking, it can be deleted.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


pkarashchenko commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377435583


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   So this test will be enabled for FLAT build only?



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


pkarashchenko commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377435035


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   Ok.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-31 Thread via GitHub


TaiJuWu commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1377428588


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   The implement of pthread_spin_lock is different with kernel spinlock.
   My initial idea is testing kernel spinlock.



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-30 Thread via GitHub


pkarashchenko commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1375911386


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();

Review Comment:
   Maybe better use `pthread_spin_lock`?



-- 
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-unsubscr...@nuttx.apache.org

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



Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-30 Thread via GitHub


pkarashchenko commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1375911994


##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();
+  g_result++;
+  spin_unlock();
+}
+}
+
+/
+ * Public Functions
+ /
+
+void spinlock_bench_main(void)
+{
+  int status;
+  g_result = 0;
+
+  clock_t start = perf_gettime();
+  for (int i = 0; i < THREAD_NUM; ++i)

Review Comment:
   ```suggestion
 for (i = 0; i < THREAD_NUM; ++i)
   ```



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;
+
+static FAR void thread_spinlock(FAR void *parameter)
+{
+  for (int i = 0; i < TEST_NUM; i++)
+{
+  spin_lock();
+  g_result++;
+  spin_unlock();
+}
+}
+
+/
+ * Public Functions
+ /
+
+void spinlock_bench_main(void)
+{
+  int status;
+  g_result = 0;
+
+  clock_t 

Re: [PR] feature: spinlock benchmark [nuttx-apps]

2023-10-30 Thread via GitHub


xiaoxiang781216 commented on code in PR #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168#discussion_r1375878152


##
benchmarks/spinlock_bench/Makefile:
##
@@ -0,0 +1,52 @@
+
+# apps/benchmarks/coremark/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+
+include $(APPDIR)/Make.defs
+
+# spinlock_bench application
+
+
+# Targets
+
+
+clean::

Review Comment:
   why need



##
benchmarks/spinlock_bench/Makefile:
##
@@ -0,0 +1,52 @@
+
+# apps/benchmarks/coremark/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+
+include $(APPDIR)/Make.defs
+
+# spinlock_bench application
+
+
+# Targets
+
+
+clean::
+   $(call DELFILE, $(OBJS))
+
+# Download and unpack tarball if no git repo found
+
+distclean::

Review Comment:
   ditto



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@
+/
+ * apps/benchmarks/spinlock_bench/spinlock_bench.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ /
+
+/
+ * Included Files
+ /
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/
+ * Pre-processor Definitions
+ /
+
+#define TEST_NUM CONFIG_SPINLOCK_MULTITHREAD
+#define THREAD_NUM CONFIG_SPINLOCK_MULTITHREAD
+
+/
+ * Private Data
+ /
+
+static spinlock_t lock = SP_UNLOCKED;
+
+static pthread_t g_thread[THREAD_NUM];
+
+static int g_result = 0;

Review Comment:
   let's pass g_result and lock through thread's parameter



##
benchmarks/spinlock_bench/spinlock_bench.c:
##
@@ -0,0 +1,89 @@

[PR] feature: spinlock benchmark [nuttx-apps]

2023-10-29 Thread via GitHub


TaiJuWu opened a new pull request, #2168:
URL: https://github.com/apache/nuttx-apps/pull/2168

   ## Summary
   spinlock benchmark
   ## Impact
   None
   ## Testing
   local build
   


-- 
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-unsubscr...@nuttx.apache.org

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