Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-08 Thread via GitHub
xiaoxiang781216 merged PR #16194: URL: https://github.com/apache/nuttx/pull/16194 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nu

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-07 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2857383471 OK, thanks for the detailed explanation, ti's clear to me that we need at least one holder for binary semaphore. -- This is an automated message from the Apache Git Service. To

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2857114818 As this seems to be difficult subject, I'll try to explain how the priority boost and restore works here, and why the thread/TCB needs to keep a list of priority boosts. It is not really

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2856829299 > > But POSIX never define the priority inheritance and priority ceiling for counting semaphore. > > As I said, the logic is there to support necessary priority inheritance

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076652731 ## sched/semaphore/sem_post.c: ## @@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem) * initialized if the semaphore is to used for signaling purposes.

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076136934 ## sched/semaphore/sem_post.c: ## @@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem) * initialized if the semaphore is to used for signaling purposes. */

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076136934 ## sched/semaphore/sem_post.c: ## @@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem) * initialized if the semaphore is to used for signaling purposes. */

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076132252 ## sched/semaphore/sem_wait.c: ## @@ -126,6 +171,13 @@ int nxsem_wait_slow(FAR sem_t *sem) rtcb->waitobj = sem; + /* In case of a mutex, store the prev

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076134668 ## sched/semaphore/sem_post.c: ## @@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem) * initialized if the semaphore is to used for signaling purposes. */

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076132252 ## sched/semaphore/sem_wait.c: ## @@ -126,6 +171,13 @@ int nxsem_wait_slow(FAR sem_t *sem) rtcb->waitobj = sem; + /* In case of a mutex, store the prev

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2076022628 ## sched/semaphore/sem_post.c: ## @@ -116,7 +153,10 @@ int nxsem_post_slow(FAR sem_t *sem) * initialized if the semaphore is to used for signaling purposes.

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
patacongo commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854789114 > But POSIX never define the priority inheritance and priority ceiling for counting semaphore. As I said, the logic is there to support necessary priority inheritance in a realti

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854788694 > > 2. Remove the code which track multiple holder for counting semaphore since it never work as expect and impact the real time > > "never work as expect" _might_ not be co

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
pussuw commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854759698 > Counting semaphore is normally waited(event) in one thread, but posted(event) in another thread(or even interrupt context) yes in this case using priority inheritance is totally wrong. F

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854746686 > 2. Remove the code which track multiple holder for counting semaphore since it never work as expect and impact the real time "never work as expect" *might* not be correct. I do a

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2075559102 ## sched/semaphore/sem_post.c: ## @@ -85,19 +87,54 @@ int nxsem_post_slow(FAR sem_t *sem) flags = enter_critical_section(); - /* Check the maximum allowable va

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854659321 > > @patacongo could you give some comment about this problem? > > If this feature is removed, you will re-introduce priority inheritance issues and damage realtime performa

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
patacongo commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854544906 > @patacongo could you give some comment about this problem? If this feature is removed, you will re-introduce priority inheritance issues and damage realtime performance. That i

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2075344025 ## sched/semaphore/sem_waitirq.c: ## @@ -72,31 +72,54 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task();

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2854058081 > > It doesn't make sense to boost the thread which pass nxsem_wait on a counting semaphore, since the priority boost is meaningful only for a mutex(binary semaphore). That's why

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2075158766 ## sched/semaphore/sem_waitirq.c: ## @@ -72,31 +72,55 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task();

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074862627 ## libs/libc/semaphore/sem_getvalue.c: ## @@ -65,7 +69,23 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval) { if (sem != NULL && sval != NULL) { - *s

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074866117 ## libs/libc/semaphore/sem_getvalue.c: ## @@ -67,25 +63,9 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval) { - if (sem != NULL && sval != NULL) + if (sem !=

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-06 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074856652 ## include/nuttx/mutex.h: ## @@ -354,407 +384,497 @@ void nxmutex_reset(FAR mutex_t *mutex); *

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074827578 ## sched/semaphore/sem_waitirq.c: ## @@ -72,31 +72,55 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task(); FAR se

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074821911 ## sched/semaphore/sem_trywait.c: ## @@ -63,8 +63,11 @@ int nxsem_trywait_slow(FAR sem_t *sem) { irqstate_t flags; - int32_t semcount; - int ret; + int ret = -

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2074810210 ## sched/semaphore/sem_destroy.c: ## @@ -61,6 +61,9 @@ int nxsem_destroy(FAR sem_t *sem) { int32_t old; + bool mutex = NXSEM_IS_MUTEX(sem); + FAR atomic_t *cons

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2853411481 > It doesn't make sense to boost the thread which pass nxsem_wait on a counting semaphore, since the priority boost is meaningful only for a mutex(binary semaphore). That's why I sug

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2853378798 > > @jlaitine after this patchset get merged, we can simplify the holder logic for priority inheritance since: > > > > 1. Don't track the multiple holders since mutex always

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2853322370 > @jlaitine after this patchset get merged, we can simplify the holder logic for priority inheritance since: > > 1. Don't track the multiple holders since mutex always can have one

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2851402290 @jlaitine after this patchset get merged, we can simplify the holder logic for priority inheritance since: 1. Don't track the multiple holders since mutex always can have on

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-05 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2073187368 ## libs/libc/semaphore/sem_getvalue.c: ## @@ -65,7 +69,23 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval) { if (sem != NULL && sval != NULL) { -

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2847119201 > > > > since the current code base never add const to the local integer variables even they doesn't change after initialization. > > > > > > > > > Why not? I'll change this if

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2846715665 Fixed one style review comment which I missed before ( change of dq_peek() != NULL -> !dq_empty() ) -- This is an automated message from the Apache Git Service. To respond to the messa

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071315661 ## sched/semaphore/sem_wait.c: ## @@ -86,19 +89,62 @@ int nxsem_wait_slow(FAR sem_t *sem) /* Check if the lock is available */ - if (atomic_fetch_sub(NXSEM_COU

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071315094 ## sched/semaphore/sem_reset.c: ## @@ -76,38 +81,65 @@ int nxsem_reset(FAR sem_t *sem, int16_t count) flags = enter_critical_section(); - /* A negative count i

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071312619 ## sched/semaphore/sem_wait.c: ## @@ -86,19 +89,62 @@ int nxsem_wait_slow(FAR sem_t *sem) /* Check if the lock is available */ - if (atomic_fetch_sub(NXSEM_COU

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071312619 ## sched/semaphore/sem_wait.c: ## @@ -86,19 +89,62 @@ int nxsem_wait_slow(FAR sem_t *sem) /* Check if the lock is available */ - if (atomic_fetch_sub(NXSEM_COU

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071307167 ## sched/semaphore/sem_trywait.c: ## @@ -74,29 +77,57 @@ int nxsem_trywait_slow(FAR sem_t *sem) /* If the semaphore is available, give it to the requesting task *

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071307942 ## sched/semaphore/sem_wait.c: ## @@ -71,9 +71,12 @@ int nxsem_wait_slow(FAR sem_t *sem) { - FAR struct tcb_s *rtcb; + FAR struct tcb_s *rtcb = this_task(); i

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-05-02 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2071291015 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2067898824 ## sched/semaphore/sem_post.c: ## @@ -73,10 +73,12 @@ int nxsem_post_slow(FAR sem_t *sem) { FAR struct tcb_s *stcb = NULL; irqstate_t flags; - int32_t s

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2067898000 ## sched/semaphore/sem_destroy.c: ## @@ -61,6 +61,9 @@ int nxsem_destroy(FAR sem_t *sem) { int32_t old; + const bool mutex = NXSEM_IS_MUTEX(sem); + FAR a

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2067740893 ## sched/semaphore/sem_post.c: ## @@ -156,7 +195,17 @@ int nxsem_post_slow(FAR sem_t *sem) * it is awakened. */ - nxsem_add_h

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065980010 ## libs/libc/misc/lib_mutex.c: ## @@ -195,9 +140,11 @@ bool nxmutex_is_hold(FAR mutex_t *mutex) * *

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065979507 ## libs/libc/misc/lib_mutex.c: ## @@ -177,7 +122,7 @@ int nxmutex_destroy(FAR mutex_t *mutex) bool nxmutex_is_hold(FAR mutex_t *mutex) Review Comment: _SCHED_GE

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065975368 ## libs/libc/misc/lib_mutex.c: ## @@ -120,7 +98,6 @@ int nxmutex_init(FAR mutex_t *mutex) return ret; } - mutex->holder = NXMUTEX_NO_HOLDER; Review Com

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-29 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065671928 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAI

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2837573228 A bunch of style changes just to please some reviewers, no functional change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to Gi

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r206613 ## sched/semaphore/sem_destroy.c: ## @@ -61,6 +61,9 @@ int nxsem_destroy(FAR sem_t *sem) { int32_t old; + const bool mutex = NXSEM_IS_MUTEX(sem); + FAR atomic_t

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065541572 ## sched/semaphore/sem_post.c: ## @@ -156,7 +195,17 @@ int nxsem_post_slow(FAR sem_t *sem) * it is awakened. */ - nxsem_add_holder_t

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065542615 ## sched/semaphore/sem_reset.c: ## @@ -76,38 +81,65 @@ int nxsem_reset(FAR sem_t *sem, int16_t count) flags = enter_critical_section(); - /* A negative count i

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065540627 ## sched/semaphore/sem_post.c: ## @@ -85,19 +87,54 @@ int nxsem_post_slow(FAR sem_t *sem) flags = enter_critical_section(); - /* Check the maximum allowable va

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065540110 ## sched/semaphore/sem_post.c: ## @@ -73,10 +73,12 @@ int nxsem_post_slow(FAR sem_t *sem) { FAR struct tcb_s *stcb = NULL; irqstate_t flags; - int32_t sem_coun

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065539704 ## sched/semaphore/sem_post.c: ## @@ -85,19 +87,54 @@ int nxsem_post_slow(FAR sem_t *sem) flags = enter_critical_section(); - /* Check the maximum allowable va

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065538672 ## sched/semaphore/sem_holder.c: ## @@ -876,7 +876,9 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem) { /* Check our assumptions */ - DEBUGASSERT(

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2065537698 ## sched/semaphore/sem_holder.c: ## @@ -876,7 +876,9 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem) { /* Check our assumptions */ - DEBUGASSERT(

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2063564754 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2063569782 ## sched/semaphore/sem_waitirq.c: ## @@ -72,30 +72,54 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task(); FAR se

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-28 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2063564754 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2834159189 > > > since the current code base never add const to the local integer variables even they doesn't change after initialization. > > > > > > Why not? I'll change this if I get a

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2834063080 > > since the current code base never add const to the local integer variables even they doesn't change after initialization. > > Why not? I'll change this if I get a second

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062926746 ## sched/semaphore/sem_waitirq.c: ## @@ -72,30 +72,54 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task();

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062917757 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAI

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2834026328 > since the current code base never add const to the local integer variables even they doesn't change after initialization. Why not? -- This is an automated message from

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062913438 ## libs/libc/misc/lib_mutex.c: ## @@ -35,30 +35,14 @@ * Pre-processor Definitions / -

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062913034 ## sched/semaphore/sem_waitirq.c: ## @@ -72,30 +72,54 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { FAR struct tcb_s *rtcb = this_task(); FAR se

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062910152 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062910152 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-27 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2062909627 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061222786 ## sched/semaphore/sem_recover.c: ## @@ -104,7 +105,23 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061217016 ## sched/semaphore/sem_holder.c: ## @@ -876,7 +876,9 @@ void nxsem_canceled(FAR struct tcb_s *stcb, FAR sem_t *sem) { /* Check our assumptions */ - DEBUG

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061353160 ## libs/libc/semaphore/sem_trywait.c: ## @@ -128,8 +129,9 @@ int nxsem_trywait(FAR sem_t *sem) #endif ) { - int32_t old = 1; - return ato

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061338927 ## libs/libc/misc/lib_mutex.c: ## @@ -195,9 +140,11 @@ bool nxmutex_is_hold(FAR mutex_t *mutex) * **

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061340132 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAI

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2832245430 > @xiaoxiang781216 I disagree on your request for removing the const in many places. what is the reason why you want that? it just tells both the compiler and reader that the valu

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061257154 ## sched/semaphore/sem_post.c: ## @@ -73,10 +73,12 @@ int nxsem_post_slow(FAR sem_t *sem) { FAR struct tcb_s *stcb = NULL; irqstate_t flags; - int32_t sem_coun

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061255959 ## libs/libc/semaphore/sem_trywait.c: ## @@ -128,8 +129,9 @@ int nxsem_trywait(FAR sem_t *sem) #endif ) { - int32_t old = 1; - return atomic_try

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061256889 ## libs/libc/semaphore/sem_wait.c: ## @@ -156,8 +157,9 @@ int nxsem_wait(FAR sem_t *sem) # endif ) { - int32_t old = 1; - if (atomic_try_cmpxch

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061256667 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2832026530 @xiaoxiang781216 I disagree on your request for removing the const in many places. what is the reason why you want that? it just tells both the compiler and reader that the value is not

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061257731 ## libs/libc/misc/lib_mutex.c: ## @@ -195,9 +140,11 @@ bool nxmutex_is_hold(FAR mutex_t *mutex) * *

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061257020 ## sched/semaphore/sem_destroy.c: ## @@ -61,6 +61,9 @@ int nxsem_destroy(FAR sem_t *sem) { int32_t old; + const bool mutex = NXSEM_IS_MUTEX(sem); Review Comment

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061256810 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061256356 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAITLIST_I

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-26 Thread via GitHub
xiaoxiang781216 commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2061204544 ## include/nuttx/semaphore.h: ## @@ -45,23 +45,42 @@ /* semcount, flags, waitlist, hhead */ #define NXSEM_INITIALIZER(c, f) \ - {(c), (f), SEM_WAI

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060240413 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(s

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060189145 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060189145 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060173828 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(s

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060137404 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060138277 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060137404 ## sched/semaphore/sem_recover.c: ## @@ -100,7 +101,39 @@ void nxsem_recover(FAR struct tcb_s *tcb) * place. */ - atomic_fetch_add(NXSEM_COUNT(sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060112180 ## sched/semaphore/sem_post.c: ## @@ -85,19 +87,54 @@ int nxsem_post_slow(FAR sem_t *sem) flags = enter_critical_section(); - /* Check the maximum allowable valu

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2060111412 ## sched/semaphore/sem_recover.c: ## @@ -86,7 +86,8 @@ void nxsem_recover(FAR struct tcb_s *tcb) if (tcb->task_state == TSTATE_WAIT_SEM) { FAR sem_t *sem

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-25 Thread via GitHub
jlaitine commented on PR #16194: URL: https://github.com/apache/nuttx/pull/16194#issuecomment-2829681915 @pussuw I now modified the nxsem_reset for mutex somewhat acc. to your feedback, and re-tested that it works for me. Please re-check that part! -- This is an automated message from the

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-24 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2059578589 ## sched/semaphore/sem_wait.c: ## @@ -218,6 +271,16 @@ int nxsem_wait_slow(FAR sem_t *sem) #endif } + /* If this now holds the mutex, set the holder TID and t

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-24 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2059591043 ## sched/semaphore/sem_post.c: ## @@ -85,19 +87,54 @@ int nxsem_post_slow(FAR sem_t *sem) flags = enter_critical_section(); - /* Check the maximum allowable va

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-24 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2059578589 ## sched/semaphore/sem_wait.c: ## @@ -218,6 +271,16 @@ int nxsem_wait_slow(FAR sem_t *sem) #endif } + /* If this now holds the mutex, set the holder TID and t

Re: [PR] Enable mutex functionality in nxsem [nuttx]

2025-04-24 Thread via GitHub
jlaitine commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2059569009 ## libs/libc/semaphore/sem_init.c: ## @@ -62,15 +62,15 @@ * / -int nxsem_init(FAR sem

  1   2   3   >