You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "zyfeier (via GitHub)" <gi...@apache.org> on 2023/02/24 10:07:45 UTC

[GitHub] [nuttx] zyfeier opened a new pull request, #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

zyfeier opened a new pull request, #8645:
URL: https://github.com/apache/nuttx/pull/8645

   ## Summary
   
   1. Move nxmutex to sched,  split the mutex interface into nxmutex_ and mutex_, userspace can only use mutex_ interface;
   2. Add mutex_clocklock, mutex_set_protocol and mutex_get_protocol interface;
   3. Mutex is not cancellation point, delete cancellation point check;
   
   ## Impact
   
   Mutex
   
   ## Testing
   
   sabre-6quad:nsh ostest


-- 
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


[GitHub] [nuttx] gustavonihei commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "gustavonihei (via GitHub)" <gi...@apache.org>.
gustavonihei commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1117150587


##########
libs/libnx/nxfonts/nxfonts_cache.c:
##########
@@ -745,7 +745,7 @@ FCACHE nxf_cache_connect(enum nx_fontid_e fontid,
  *   fhandle - A font cache handle previously returned by
  *             nxf_cache_connect();
  *
- * Returned Value:
+ * Returned Value:mutex_

Review Comment:
   ```suggestion
    * Returned Value:
   ```



-- 
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


[GitHub] [nuttx] pkarashchenko commented on pull request #8645: mutex: move nxmutex to sched

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1462173918

   I will take a look over the weekend.


-- 
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


[GitHub] [nuttx] zyfeier closed pull request #8645: mutex: move nxmutex to sched

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier closed pull request #8645: mutex: move nxmutex to sched
URL: https://github.com/apache/nuttx/pull/8645


-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1126765864


##########
sched/mutex/mutex_unlock.c:
##########
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * sched/mutex/mutex_unlock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+

Review Comment:
   add assert.h



##########
sched/mutex/mutex_unlock.c:
##########
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * sched/mutex/mutex_unlock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include "mutex.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_unlock
+ *
+ * Description:
+ *   This function attempts to unlock the mutex referenced by 'mutex'.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ * Assumptions:
+ *   This function may be called from an interrupt handler.
+ *
+ ****************************************************************************/
+
+int nxmutex_unlock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  if (nxmutex_is_reset(mutex))
+    {
+      return OK;
+    }
+
+  DEBUGASSERT(nxmutex_is_hold(mutex));
+
+  mutex->holder = NXMUTEX_NO_HOLDER;
+
+  ret = nxsem_post(&mutex->sem);
+  if (ret < 0)
+    {
+      mutex->holder = nxsched_gettid();
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_unlock
+ *
+ * Description:
+ *   This function attempts to unlock the recursive mutex
+ *   referenced by 'rmutex'.
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ * Assumptions:
+ *   This function may be called from an interrupt handler.
+ *
+ ****************************************************************************/
+
+int nxrmutex_unlock(FAR rmutex_t *rmutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_timedlock.c:
##########
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * sched/mutex/mutex_timedlock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_timedlock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   mutex   - Mutex object
+ *   timeout - The time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxmutex_timedlock(FAR mutex_t *mutex, unsigned int timeout)
+{
+  int ret;
+  struct timespec now;
+  struct timespec delay;
+  struct timespec rqtp;
+
+  clock_gettime(CLOCK_MONOTONIC, &now);
+  clock_ticks2time(MSEC2TICK(timeout), &delay);
+  clock_timespec_add(&now, &delay, &rqtp);
+
+  /* Wait until we get the lock or until the timeout expires */
+
+  do
+    {
+      ret = nxsem_clockwait(&mutex->sem, CLOCK_MONOTONIC, &rqtp);
+    }
+  while (ret == -EINTR || ret == -ECANCELED);
+
+  if (ret >= 0)
+    {
+      mutex->holder = nxsched_gettid();
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_timedlock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   rmutex  - Rmutex object
+ *   timeout - The time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *   ECANCELED May be returned if the thread is canceled while waiting.
+ *
+ ****************************************************************************/
+
+int nxrmutex_timedlock(FAR rmutex_t *rmutex, unsigned int timeout)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_restorelock.c:
##########
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * sched/mutex/mutex_restorelock.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_restorelock
+ *
+ * Description:
+ *   This function attempts to restore the mutex.
+ *
+ * Parameters:
+ *   mutex   - mutex descriptor.
+ *   locked  - true: it's mean that the mutex is broke success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure
+ *
+ ****************************************************************************/
+
+int nxmutex_restorelock(FAR mutex_t *mutex, bool locked)
+{
+  return locked ? nxmutex_lock(mutex) : OK;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_restorelock
+ *
+ * Description:
+ *   This function attempts to restore the recursive mutex.
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *   count  - Count after restore.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxrmutex_restorelock(FAR rmutex_t *rmutex, unsigned int count)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_destroy.c:
##########
@@ -0,0 +1,82 @@
+/****************************************************************************
+ * sched/mutex/mutex_destroy.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_destroy
+ *
+ * Description:
+ *   This function initializes the UNNAMED mutex. Following a
+ *   successful call to nxmutex_init(), the mutex may be used in subsequent
+ *   calls to nxmutex_lock(), nxmutex_unlock(), and nxmutex_trylock().  The
+ *   mutex remains usable until it is destroyed.
+ *
+ * Parameters:
+ *   mutex - Semaphore to be destroyed
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *
+ ****************************************************************************/
+
+int nxmutex_destroy(FAR mutex_t *mutex)
+{
+  int ret = nxsem_destroy(&mutex->sem);
+  mutex->holder = NXMUTEX_NO_HOLDER;
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_destroy
+ *
+ * Description:
+ *   This function destroy the UNNAMED recursive mutex.
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex to be destroyed
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *
+ ****************************************************************************/
+
+int nxrmutex_destroy(FAR rmutex_t *rmutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_reset.c:
##########
@@ -0,0 +1,89 @@
+/****************************************************************************
+ * sched/mutex/mutex_reset.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 <nuttx/mutex.h>
+
+#include "mutex.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NXMUTEX_RESET         ((pid_t)-2)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_reset
+ *
+ * Description:
+ *   This function check whether the mutex is reset
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_reset(FAR mutex_t *mutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_reset.c:
##########
@@ -0,0 +1,89 @@
+/****************************************************************************
+ * sched/mutex/mutex_reset.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 <nuttx/mutex.h>
+
+#include "mutex.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NXMUTEX_RESET         ((pid_t)-2)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_reset
+ *
+ * Description:
+ *   This function check whether the mutex is reset
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_reset(FAR mutex_t *mutex)
+{
+  return mutex->holder == NXMUTEX_RESET;
+}
+
+/****************************************************************************
+ * Name: nxmutex_reset
+ *
+ * Description:
+ *   This function reset lock state.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ ****************************************************************************/
+
+void nxmutex_reset(FAR mutex_t *mutex)
+{
+  mutex->holder = NXMUTEX_RESET;
+  nxsem_reset(&mutex->sem, 1);
+}
+
+/****************************************************************************
+ * Name: nxrmutex_reset
+ *
+ * Description:
+ *   This function reset lock state.
+ *
+ * Parameters:
+ *   rmutex - rmutex descriptor.
+ *
+ ****************************************************************************/
+
+void nxrmutex_reset(FAR rmutex_t *rmutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_restorelock.c:
##########
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * sched/mutex/mutex_restorelock.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_restorelock
+ *
+ * Description:
+ *   This function attempts to restore the mutex.
+ *
+ * Parameters:
+ *   mutex   - mutex descriptor.
+ *   locked  - true: it's mean that the mutex is broke success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure
+ *
+ ****************************************************************************/
+
+int nxmutex_restorelock(FAR mutex_t *mutex, bool locked)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_trylock.c:
##########
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * sched/mutex/mutex_trylock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_trylock
+ *
+ * Description:
+ *   This function locks the mutex only if the mutex is currently not locked.
+ *   If the mutex has been locked already, the call returns without blocking.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ *     -EINVAL - Invalid attempt to lock the mutex
+ *     -EAGAIN - The mutex is not available.
+ *
+ ****************************************************************************/
+
+int nxmutex_trylock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  if (nxmutex_is_hold(mutex))
+    {
+      return -EAGAIN;
+    }
+
+  ret = nxsem_trywait(&mutex->sem);
+  if (ret >= 0)
+    {
+      mutex->holder = nxsched_gettid();
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_trylock
+ *
+ * Description:
+ *   This function locks the recursive mutex if the recursive mutex is
+ *   currently not locked or the same thread call.
+ *   If the recursive mutex is locked and other thread call it,
+ *   the call returns without blocking.
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ *     -EINVAL - Invalid attempt to lock the recursive mutex
+ *     -EAGAIN - The recursive mutex is not available.
+ *
+ ****************************************************************************/
+
+int nxrmutex_trylock(FAR rmutex_t *rmutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_is_hold.c:
##########
@@ -0,0 +1,50 @@
+/****************************************************************************
+ * sched/mutex/mutex_is_hold.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_hold
+ *
+ * Description:
+ *   This function check whether the caller hold the mutex
+ *   referenced by 'mutex'.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   Return true if mutex is hold by current thread.
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_hold(FAR mutex_t *mutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_lock.c:
##########
@@ -0,0 +1,115 @@
+/****************************************************************************
+ * sched/mutex/mutex_lock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_lock
+ *
+ * Description:
+ *   This function attempts to lock the mutex referenced by 'mutex'.  The
+ *   mutex is implemented with a semaphore, so if the semaphore value is
+ *   (<=) zero, then the calling task will not return until it successfully
+ *   acquires the lock.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_lock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  DEBUGASSERT(!nxmutex_is_hold(mutex));
+  for (; ; )
+    {
+      /* Take the semaphore (perhaps waiting) */
+
+      ret = nxsem_wait(&mutex->sem);
+      if (ret >= 0)
+        {
+          mutex->holder = nxsched_gettid();
+          break;
+        }
+
+      if (ret != -EINTR && ret != -ECANCELED)
+        {
+          break;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_lock
+ *
+ * Description:
+ *   This function attempts to lock the recursive mutex referenced by
+ *   'rmutex'.The recursive mutex can be locked multiple times in the same
+ *   thread.
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxrmutex_lock(FAR rmutex_t *rmutex)

Review Comment:
   could be done in libc



##########
sched/mutex/mutex_breaklock.c:
##########
@@ -0,0 +1,105 @@
+/****************************************************************************
+ * sched/mutex/mutex_breaklock.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Input Parameters:
+ *   mutex   - Mutex descriptor.
+ *
+ * Output Parameters:
+ *   locked  - Is the mutex break success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_breaklock(FAR mutex_t *mutex, FAR bool *locked)
+{
+  int ret = OK;
+
+  *locked = false;
+  if (nxmutex_is_hold(mutex))
+    {
+      ret = nxmutex_unlock(mutex);
+      if (ret >= 0)
+        {
+          *locked = true;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the recursive mutex
+ *
+ * Input Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *
+ * Output Parameters:
+ *   count  - Return the count value before break.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxrmutex_breaklock(FAR rmutex_t *rmutex, FAR unsigned int *count)

Review Comment:
   could be done in libc



-- 
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


[GitHub] [nuttx] gustavonihei commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "gustavonihei (via GitHub)" <gi...@apache.org>.
gustavonihei commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1117156199


##########
sched/mutex/mutex_breaklock.c:
##########
@@ -0,0 +1,173 @@
+/****************************************************************************
+ * sched/mutex/mutex_breaklock.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 <nuttx/mutex.h>
+
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Parameters:
+ *   mutex   - Mutex descriptor.
+ *   locked  - Is the mutex break success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_breaklock(FAR mutex_t *mutex, FAR bool *locked)
+{
+  int ret = OK;
+
+  *locked = false;
+  if (nxmutex_is_hold(mutex))
+    {
+      ret = nxmutex_unlock(mutex);
+      if (ret >= 0)
+        {
+          *locked = true;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the recursive mutex
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.

Review Comment:
   ```suggestion
    * Input Parameters:
    *   rmutex - Recursive mutex descriptor.
    *
    * Output Parameters:
    *   count  -
   ```
   Missing documentation for `count`.



-- 
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


[GitHub] [nuttx] pkarashchenko commented on pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1443628346

   Why do we need nxmutex in user space. There is already a pthread_mutex interface available.


-- 
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


[GitHub] [nuttx] gustavonihei commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "gustavonihei (via GitHub)" <gi...@apache.org>.
gustavonihei commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1117154061


##########
sched/mutex/mutex_breaklock.c:
##########
@@ -0,0 +1,173 @@
+/****************************************************************************
+ * sched/mutex/mutex_breaklock.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 <nuttx/mutex.h>
+
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Parameters:
+ *   mutex   - Mutex descriptor.
+ *   locked  - Is the mutex break success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_breaklock(FAR mutex_t *mutex, FAR bool *locked)
+{
+  int ret = OK;
+
+  *locked = false;
+  if (nxmutex_is_hold(mutex))
+    {
+      ret = nxmutex_unlock(mutex);
+      if (ret >= 0)
+        {
+          *locked = true;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the recursive mutex
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.

Review Comment:
   Missing documentation for `count`.



-- 
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


[GitHub] [nuttx] gustavonihei commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "gustavonihei (via GitHub)" <gi...@apache.org>.
gustavonihei commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1117160537


##########
sched/mutex/mutex_breaklock.c:
##########
@@ -0,0 +1,173 @@
+/****************************************************************************
+ * sched/mutex/mutex_breaklock.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 <nuttx/mutex.h>
+
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Parameters:
+ *   mutex   - Mutex descriptor.
+ *   locked  - Is the mutex break success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_breaklock(FAR mutex_t *mutex, FAR bool *locked)
+{
+  int ret = OK;
+
+  *locked = false;
+  if (nxmutex_is_hold(mutex))
+    {
+      ret = nxmutex_unlock(mutex);
+      if (ret >= 0)
+        {
+          *locked = true;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nxrmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the recursive mutex
+ *
+ * Parameters:
+ *   rmutex - Recursive mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxrmutex_breaklock(FAR rmutex_t *rmutex, FAR unsigned int *count)
+{
+  int ret = OK;
+
+  *count = 0;
+  if (nxrmutex_is_hold(rmutex))
+    {
+      *count = rmutex->count;
+      rmutex->count = 0;
+      ret = nxmutex_unlock(&rmutex->mutex);
+      if (ret < 0)
+        {
+          rmutex->count = *count;
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: mutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Parameters:
+ *   mutex   - Mutex descriptor.
+ *   locked  - Is the mutex break success

Review Comment:
   ```suggestion
    * Input Parameters:
    *   mutex   - Mutex descriptor.
    *
     * Output Parameters:
    *   locked  - Is the mutex break success
   ```
   nit: The `Output Parameters` section is more suitable for documenting `locked`.



-- 
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


[GitHub] [nuttx] zyfeier commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1133441798


##########
libs/libc/mutex/mutex_is_hold.c:
##########
@@ -0,0 +1,50 @@
+/****************************************************************************
+ * libs/libc/mutex/mutex_is_hold.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_hold
+ *
+ * Description:
+ *   This function check whether the caller hold the mutex
+ *   referenced by 'mutex'.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   Return true if mutex is hold by current thread.
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_hold(FAR mutex_t *mutex)

Review Comment:
   mutex.h include sched.h will cause compilation failure, so reserve this function.



-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1125441753


##########
sched/mutex/mutex_reset.c:
##########
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * sched/mutex/mutex_reset.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 <nuttx/mutex.h>
+
+#include "mutex.h"
+
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)

Review Comment:
   don't need since the code neve build in userspace now.



##########
sched/mutex/mutex.h:
##########
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * sched/mutex/mutex.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __SCHED_MUTEX_MUTEX_H
+#define __SCHED_MUTEX_MUTEX_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/mutex.h>
+
+#include <stdbool.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)

Review Comment:
   remove the condition check which is redundant now.



##########
syscall/syscall.csv:
##########
@@ -70,6 +70,28 @@
 "mq_timedsend","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","FAR const char *","size_t","unsigned int","FAR const struct timespec *"
 "mq_unlink","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","FAR const char *"
 "munmap","sys/mman.h","","int","FAR void *","size_t"
+"nxmutex_init","nuttx/mutex.h","","int","FAR mutex_t *"

Review Comment:
   move after line 98 and keep the new entry in order.



##########
include/sys/syscall_lookup.h:
##########
@@ -380,3 +380,26 @@ SYSCALL_LOOKUP(munmap,                     2)
 #ifdef CONFIG_CRYPTO_RANDOM_POOL
   SYSCALL_LOOKUP(arc4random_buf,           2)
 #endif
+
+SYSCALL_LOOKUP(nxmutex_init,               1)
+SYSCALL_LOOKUP(nxmutex_destroy,            1)
+SYSCALL_LOOKUP(nxmutex_is_locked,          1)
+SYSCALL_LOOKUP(nxmutex_is_hold,            1)
+SYSCALL_LOOKUP(nxmutex_lock,               1)
+SYSCALL_LOOKUP(nxmutex_timedlock,          2)
+SYSCALL_LOOKUP(nxmutex_clocklock,          2)
+SYSCALL_LOOKUP(nxmutex_trylock,            1)
+SYSCALL_LOOKUP(nxmutex_unlock,             1)
+SYSCALL_LOOKUP(nxmutex_breaklock,          2)
+SYSCALL_LOOKUP(nxmutex_restorelock,        2)
+SYSCALL_LOOKUP(nxmutex_set_protocol,       2)
+SYSCALL_LOOKUP(nxmutex_get_protocol,       2)
+SYSCALL_LOOKUP(nxrmutex_init,              1)
+SYSCALL_LOOKUP(nxrmutex_destroy,           1)
+SYSCALL_LOOKUP(nxrmutex_lock,              1)
+SYSCALL_LOOKUP(nxrmutex_timedlock,         2)
+SYSCALL_LOOKUP(nxrmutex_clocklock,         2)
+SYSCALL_LOOKUP(nxrmutex_trylock,           1)
+SYSCALL_LOOKUP(nxrmutex_unlock,            1)
+SYSCALL_LOOKUP(nxrmutex_breaklock,         2)
+SYSCALL_LOOKUP(nxrmutex_restorelock,       2)

Review Comment:
   let's keep order



##########
include/sys/syscall_lookup.h:
##########
@@ -380,3 +380,26 @@ SYSCALL_LOOKUP(munmap,                     2)
 #ifdef CONFIG_CRYPTO_RANDOM_POOL
   SYSCALL_LOOKUP(arc4random_buf,           2)
 #endif
+
+SYSCALL_LOOKUP(nxmutex_init,               1)

Review Comment:
   function which doesn't touch kernel space data or function should move to libs/libc/mutex. nxmutex_init is one of example.



-- 
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


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1133730229


##########
include/nuttx/mutex.h:
##########
@@ -126,11 +130,28 @@ int nxmutex_destroy(FAR mutex_t *mutex);
  *   mutex - mutex descriptor.
  *
  * Return Value:
+ *   Return true if mutex is hold by current thread.
  *
  ****************************************************************************/
 
 bool nxmutex_is_hold(FAR mutex_t *mutex);
 
+/****************************************************************************
+ * Name: nxmutex_is_reset
+ *
+ * Description:
+ *   This function check whether the mutex is be reset
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   Return true if mutex is be reset.
+ *
+ ****************************************************************************/
+
+#define nxmutex_is_reset(mutex) ((mutex)->holder == NXMUTEX_RESET)

Review Comment:
   Optional
   ```suggestion
   #define nxmutex_is_reset(mutex) (NXMUTEX_HOLDER(mutex) == NXMUTEX_RESET)
   ```



##########
include/nuttx/mutex.h:
##########
@@ -438,6 +529,34 @@ int nxrmutex_trylock(FAR rmutex_t *rmutex);
 
 int nxrmutex_timedlock(FAR rmutex_t *rmutex, unsigned int timeout);
 
+/****************************************************************************
+ * Name: nxrmutex_clocklock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value

Review Comment:
   ```suggestion
    *   This function attempts to lock the mutex.  If the mutex value
   ```



##########
sched/mutex/mutex_timedlock.c:
##########
@@ -0,0 +1,75 @@
+/****************************************************************************
+ * sched/mutex/mutex_timedlock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_timedlock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   mutex   - Mutex object
+ *   timeout - The time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxmutex_timedlock(FAR mutex_t *mutex, unsigned int timeout)
+{
+  int ret;
+
+  /* Wait until we get the lock or until the timeout expires */
+
+  do
+    {
+      ret = nxsem_tickwait(&mutex->sem, MSEC2TICK(timeout));
+    }
+  while (ret == -EINTR || ret == -ECANCELED);

Review Comment:
   ditto for `-ECANCELED`



##########
sched/mutex/mutex_lock.c:
##########
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * sched/mutex/mutex_lock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_lock
+ *
+ * Description:
+ *   This function attempts to lock the mutex referenced by 'mutex'.  The
+ *   mutex is implemented with a semaphore, so if the semaphore value is
+ *   (<=) zero, then the calling task will not return until it successfully
+ *   acquires the lock.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_lock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  DEBUGASSERT(!nxmutex_is_hold(mutex));
+  for (; ; )
+    {
+      /* Take the semaphore (perhaps waiting) */
+
+      ret = nxsem_wait(&mutex->sem);
+      if (ret >= 0)
+        {
+          mutex->holder = nxsched_gettid();
+          break;
+        }
+
+      if (ret != -EINTR && ret != -ECANCELED)

Review Comment:
   I'm not sure how the caller should deal with `-ECANCELED`. Un libc implementation the mutex was remapped either to `nxsem_` ro to `sem_` API, so in user space the `sem_` API was used so `enter_cancellation_point()` and `leave_cancellation_point()` was applied. Now the path of `ECANCELED` is not clear to me



##########
sched/mutex/mutex_trylock.c:
##########
@@ -0,0 +1,69 @@
+/****************************************************************************
+ * sched/mutex/mutex_trylock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_trylock
+ *
+ * Description:
+ *   This function locks the mutex only if the mutex is currently not locked.
+ *   If the mutex has been locked already, the call returns without blocking.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ *     -EINVAL - Invalid attempt to lock the mutex
+ *     -EAGAIN - The mutex is not available.
+ *
+ ****************************************************************************/
+
+int nxmutex_trylock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  if (nxmutex_is_hold(mutex))
+    {
+      return -EAGAIN;

Review Comment:
   Shouldn't `-EDEADLK` be a better candidate?



-- 
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


[GitHub] [nuttx] pkarashchenko commented on pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1452594215

   I'm still not sure about this change. I know that some time in the past I drafter something similar, but after re-thinking I'm looking into a next direction: there is already one mutex layer available in user space and it is `pthread_mutex`. I do not think we need to introduce another layer otherwise it will bring duplication. We need to think how to solve libc issue in a different way. Till now nxmutex was simply a wrapper on top of sem/nxsem, but now it seems to be something more.


-- 
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


[GitHub] [nuttx] zyfeier commented on pull request #8645: mutex: move nxmutex to sched

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1467231287

   > In general I do not see any issues that stop this PR from merging except one. I'm missing the overall roadmap for the mutex support. The nxmutex is not a cancellation point but if I recall correctly (@xiaoxiang781216 please correct me if I'm wrong) there is an intention to move pthread_mutex (and maybe pthead_rwlock) to use nxmutex interface. The pthread_mutex interface is not a cancellation point, so all seems to be fine, but pthread_rwlock is a cancellation point.
   > 
   > I really would like to re-inspect the affected area and have nxmutex discussion moving to the mailing list before we are not too far away. By the affected area I mean that `printf` for example is a cancellation point and many other places as well. I will spend some time this week to figure out if those functions rely on the `sem`/`pthread_mutex` interface in user mode and how this change will affect that.
   
   @pkarashchenko About pthread rwlock, although pthread_mutex is not a cancellation point, but pthread_cond_wait is, so i think this should be no problem. But it's still necessary to re-inspect the affected area.


-- 
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


[GitHub] [nuttx] gustavonihei commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "gustavonihei (via GitHub)" <gi...@apache.org>.
gustavonihei commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1117153002


##########
sched/mutex/mutex.h:
##########
@@ -0,0 +1,53 @@
+/****************************************************************************
+ * sched/mutex/mutex.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __SCHED_MUTEX_MUTEX_H
+#define __SCHED_MUTEX_MUTEX_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/mutex.h>
+
+#include <stdint.h>

Review Comment:
   ```suggestion
   ```
   `stdint.h` does not seem to be required here.



-- 
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


[GitHub] [nuttx] zyfeier commented on pull request #8645: mutex: move nxmutex to sched

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1462041929

   @xiaoxiang781216 @pkarashchenko Any comments on this PR? Please help to review it again.


-- 
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


[GitHub] [nuttx] zyfeier commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1133794411


##########
sched/mutex/mutex_lock.c:
##########
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * sched/mutex/mutex_lock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_lock
+ *
+ * Description:
+ *   This function attempts to lock the mutex referenced by 'mutex'.  The
+ *   mutex is implemented with a semaphore, so if the semaphore value is
+ *   (<=) zero, then the calling task will not return until it successfully
+ *   acquires the lock.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_lock(FAR mutex_t *mutex)
+{
+  int ret;
+
+  DEBUGASSERT(!nxmutex_is_hold(mutex));
+  for (; ; )
+    {
+      /* Take the semaphore (perhaps waiting) */
+
+      ret = nxsem_wait(&mutex->sem);
+      if (ret >= 0)
+        {
+          mutex->holder = nxsched_gettid();
+          break;
+        }
+
+      if (ret != -EINTR && ret != -ECANCELED)

Review Comment:
   Mutex is not a cancellation point, so don't need to check -ECANCELED, i'll delete it.



-- 
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


[GitHub] [nuttx] pkarashchenko commented on pull request #8645: mutex: move nxmutex to sched

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1479783853

   I'm planning to start mailing list discussion till the end of this week.


-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8645: mutex: move nxmutex to sched

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1133050151


##########
libs/libc/mutex/mutex_is_hold.c:
##########
@@ -0,0 +1,50 @@
+/****************************************************************************
+ * libs/libc/mutex/mutex_is_hold.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_hold
+ *
+ * Description:
+ *   This function check whether the caller hold the mutex
+ *   referenced by 'mutex'.
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *   Return true if mutex is hold by current thread.
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_hold(FAR mutex_t *mutex)

Review Comment:
   change to macro



##########
sched/mutex/mutex_breaklock.c:
##########
@@ -0,0 +1,66 @@
+/****************************************************************************
+ * sched/mutex/mutex_breaklock.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_breaklock
+ *
+ * Description:
+ *   This function attempts to break the mutex
+ *
+ * Input Parameters:
+ *   mutex   - Mutex descriptor.
+ *
+ * Output Parameters:
+ *   locked  - Is the mutex break success
+ *
+ * Return Value:
+ *   This is an internal OS interface and should not be used by applications.
+ *   It follows the NuttX internal error return policy:  Zero (OK) is
+ *   returned on success.  A negated errno value is returned on failure.
+ *   Possible returned errors:
+ *
+ ****************************************************************************/
+
+int nxmutex_breaklock(FAR mutex_t *mutex, FAR bool *locked)

Review Comment:
   could be done in userspace?



##########
libs/libc/mutex/mutex_reset.c:
##########
@@ -0,0 +1,64 @@
+/****************************************************************************
+ * libs/libc/mutex/mutex_reset.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 <nuttx/mutex.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_is_reset
+ *
+ * Description:
+ *   This function check whether the mutex is reset
+ *
+ * Parameters:
+ *   mutex - mutex descriptor.
+ *
+ * Return Value:
+ *
+ ****************************************************************************/
+
+bool nxmutex_is_reset(FAR mutex_t *mutex)

Review Comment:
   change to macro?



##########
sched/mutex/mutex_timedlock.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * sched/mutex/mutex_timedlock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>

Review Comment:
   remove



##########
sched/mutex/mutex.h:
##########
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * sched/mutex/mutex.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __SCHED_MUTEX_MUTEX_H
+#define __SCHED_MUTEX_MUTEX_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/mutex.h>
+
+#include <stdbool.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+bool nxmutex_is_reset(FAR mutex_t *mutex);

Review Comment:
   remove, declared in nuttx/mutex.h?



##########
sched/mutex/mutex_clocklock.c:
##########
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * sched/mutex/mutex_clocklock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_clocklock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   mutex       - Mutex object
+ *   abs_timeout - The abs time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxmutex_clocklock(FAR mutex_t *mutex,
+                      FAR const struct timespec *abs_timeout)
+{
+  int ret;
+
+  if (abs_timeout == NULL)
+    {
+      return nxmutex_lock(mutex);

Review Comment:
   do we need this special process



##########
sched/mutex/mutex_clocklock.c:
##########
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * sched/mutex/mutex_clocklock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_clocklock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   mutex       - Mutex object
+ *   abs_timeout - The abs time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxmutex_clocklock(FAR mutex_t *mutex,
+                      FAR const struct timespec *abs_timeout)

Review Comment:
   let's add clockid_t clockid like glibc:
   https://codebrowser.dev/glibc/glibc/sysdeps/nptl/pthread.h.html#pthread_mutex_clocklock



##########
libs/libc/mutex/mutex_clocklock.c:
##########
@@ -0,0 +1,74 @@
+/****************************************************************************
+ * libs/libc/mutex/mutex_clocklock.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 <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxrmutex_clocklock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   rmutex      - Rmutex object
+ *   abs_timeout - The abs time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxrmutex_clocklock(FAR rmutex_t *rmutex,
+                       FAR const struct timespec *abs_timeout)

Review Comment:
   add clockid_t clockid argument



##########
sched/mutex/mutex_timedlock.c:
##########
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * sched/mutex/mutex_timedlock.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 <nuttx/sched.h>
+#include <nuttx/clock.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxmutex_timedlock
+ *
+ * Description:
+ *   This function attempts to lock the mutex .  If the mutex value
+ *   is (<=) zero,then the calling task will not return until it
+ *   successfully acquires the lock or timed out
+ *
+ * Input Parameters:
+ *   mutex   - Mutex object
+ *   timeout - The time when mutex lock timed out
+ *
+ * Returned Value:
+ *   OK        The mutex successfully acquires
+ *   EINVAL    The mutex argument does not refer to a valid mutex.  Or the
+ *             thread would have blocked, and the abstime parameter specified
+ *             a nanoseconds field value less than zero or greater than or
+ *             equal to 1000 million.
+ *   ETIMEDOUT The mutex could not be locked before the specified timeout
+ *             expired.
+ *   EDEADLK   A deadlock condition was detected.
+ *
+ ****************************************************************************/
+
+int nxmutex_timedlock(FAR mutex_t *mutex, unsigned int timeout)
+{
+  int ret;
+  struct timespec now;
+  struct timespec delay;
+  struct timespec rqtp;
+
+  clock_gettime(CLOCK_MONOTONIC, &now);
+  clock_ticks2time(MSEC2TICK(timeout), &delay);
+  clock_timespec_add(&now, &delay, &rqtp);
+
+  /* Wait until we get the lock or until the timeout expires */
+
+  do
+    {
+      ret = nxsem_clockwait(&mutex->sem, CLOCK_MONOTONIC, &rqtp);

Review Comment:
   call nxsem_tickwait instead



##########
sched/mutex/mutex_trylock.c:
##########
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * sched/mutex/mutex_trylock.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 <nuttx/sched.h>
+#include <nuttx/mutex.h>
+
+#include <assert.h>

Review Comment:
   remove



-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#discussion_r1123468782


##########
include/mutex.h:
##########
@@ -0,0 +1,577 @@
+/****************************************************************************
+ * include/mutex.h

Review Comment:
   mutex.h is too general, it's easy to conflict with the 3rd party library or source code, if we put iit into include folder.



##########
include/nuttx/mutex.h:
##########
@@ -27,37 +27,94 @@
 
 #include <assert.h>
 #include <stdbool.h>
+#include <mutex.h>
 
 #include <nuttx/semaphore.h>
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define NXMUTEX_NO_HOLDER      ((pid_t)-1)
-#define NXMUTEX_INITIALIZER    {NXSEM_INITIALIZER(1, SEM_TYPE_MUTEX | \
-                                SEM_PRIO_INHERIT), NXMUTEX_NO_HOLDER}
-#define NXRMUTEX_INITIALIZER   {NXMUTEX_INITIALIZER, 0}
-
-/****************************************************************************
- * Public Type Definitions
- ****************************************************************************/
-
-struct mutex_s
-{
-  sem_t sem;
-  pid_t holder;
-};
-
-typedef struct mutex_s mutex_t;
-
-struct rmutex_s
-{
-  mutex_t mutex;
-  unsigned int count;
-};
-
-typedef struct rmutex_s rmutex_t;
+/* Most internal nxmutex_* interfaces are not available in the user space in
+ * PROTECTED and KERNEL builds.  In that context, the application mutex
+ * interfaces must be used.  The differences between the two sets of
+ * interfaces are:  (1) the nxmutex_* interfaces do not cause cancellation
+ * points and (2) they do not modify the errno variable.
+ *
+ * This is only important when compiling libraries (libc or libnx) that are
+ * used both by the OS (libkc.a and libknx.a) or by the applications
+ * (libc.a and libnx.a).  In that case, the correct interface must be
+ * used for the build context.
+ *
+ * REVISIT:  In the flat build, the same functions must be used both by
+ * the OS and by applications.  We have to use the normal user functions
+ * in this case or we will fail to set the errno or fail to create the
+ * cancellation point.
+ */
+
+#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
+#  define _MUTEX_INIT(m)              nxmutex_init(m)
+#  define _MUTEX_DESTROY(m)           nxmutex_destroy(m)
+#  define _MUTEX_BREAKLOCK(m, l)      nxmutex_breaklock(m, l)
+#  define _MUTEX_RESTORELOCK(m, l)    nxmutex_restorelock(m, l)
+#  define _MUTEX_LOCK(m)              nxmutex_lock(m)
+#  define _MUTEX_IS_LOCKED(m)         nxmutex_is_locked(m)
+#  define _MUTEX_IS_HOLD(m)           nxmutex_is_hold(m)
+#  define _MUTEX_TIMEDLOCK(m, t)      nxmutex_timedlock(m, t)
+#  define _MUTEX_CLOCKLOCK(m, t)      nxmutex_clocklock(m, t)
+#  define _MUTEX_TRYLOCK(m)           nxmutex_trylock(m)
+#  define _MUTEX_UNLOCK(m)            nxmutex_unlock(m)
+#  define _MUTEX_SET_PROTOCOL(m, p)   nxmutex_set_protocol(m, p)
+#  define _MUTEX_GET_PROTOCOL(m, p)   nxmutex_get_protocol(m, p)
+
+#  define _RMUTEX_INIT(rm)            nxrmutex_init(rm)
+#  define _RMUTEX_DESTROY(rm)         nxrmutex_destroy(rm)
+#  define _RMUTEX_BREAKLOCK(rm, l)    nxrmutex_breaklock(rm, l)
+#  define _RMUTEX_RESTORELOCK(rm, l)  nxrmutex_restorelock(rm, l)
+#  define _RMUTEX_LOCK(rm)            nxrmutex_lock(rm)
+#  define _RMUTEX_IS_LOCKED(rm)       nxrmutex_is_locked(rm)
+#  define _RMUTEX_IS_HOLD(m)          nxrmutex_is_hold(m)
+#  define _RMUTEX_TIMEDLOCK(rm, t)    nxrmutex_timedlock(rm, t)
+#  define _RMUTEX_CLOCKLOCK(rm, t)    nxrmutex_clocklock(rm, t)
+#  define _RMUTEX_TRYLOCK(rm)         nxrmutex_trylock(rm)
+#  define _RMUTEX_UNLOCK(rm)          nxrmutex_unlock(rm)
+#  define _RMUTEX_SET_PROTOCOL(rm, p) nxrmutex_set_protocol(m, p)
+#  define _RMUTEX_GET_PROTOCOL(rm, p) nxrmutex_get_protocol(m, p)
+
+#  define _MUTEX_ERRNO(r)             (-(r))
+#  define _MUTEX_ERRVAL(r)            (r)
+#else
+#  define _MUTEX_INIT(m)              nxmtx_init(m)

Review Comment:
   since mutex is a brand new type, we can design one set of function which return a negative error code directly instead modify errno.



-- 
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


[GitHub] [nuttx] zyfeier commented on pull request #8645: mutex: move nxmutex to sched and add mutex_ interface for userspace

Posted by "zyfeier (via GitHub)" <gi...@apache.org>.
zyfeier commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1452804573

   > I'm still not sure about this change. I know that some time in the past I drafter something similar, but after re-thinking I'm looking into a next direction: there is already one mutex layer available in user space and it is `pthread_mutex`. I do not think we need to introduce another layer otherwise it will bring duplication. We need to think how to solve libc issue in a different way. Till now nxmutex was simply a wrapper on top of sem/nxsem, but now it seems to be something more.
   
   @pkarashchenko
   Yes, this is only the first step of the modification, the following changes will be dependent on this modification:
   1. pthread mutex is changed to depend on nxmutex instead of nxsem.
   2. nxmutex no longer depends on nxsem and is implemented independently;
   3. Move priority inheritance from nxsem to nxmutex, and optimize the performance of priority inheritance;


-- 
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


[GitHub] [nuttx] pkarashchenko commented on pull request #8645: mutex: move nxmutex to sched

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1465903702

   > > I will take a look over the weekend.
   > 
   > @pkarashchenko do you finish the review?
   
   Done. Sorry, I experienced many delays during my trip, so was not able to review on time


-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #8645: mutex: move nxmutex to sched

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #8645:
URL: https://github.com/apache/nuttx/pull/8645#issuecomment-1465597505

   > I will take a look over the weekend.
   
   @pkarashchenko do you finish the review?


-- 
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