You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "zhhyu7 (via GitHub)" <gi...@apache.org> on 2023/07/08 15:31:54 UTC
[GitHub] [nuttx] zhhyu7 commented on pull request #9741: iob_alloc: change sem_post to count++
zhhyu7 commented on PR #9741:
URL: https://github.com/apache/nuttx/pull/9741#issuecomment-1627380846
> Incrementing the semaphore count is equivalent to calling `sem_post()`, provided that:
>
> 1. The increment is performed within a critical section (it is), and
> 2. The count before incrementing is >= 0. Is it????
>
> A count less than zero means that there are other threads waiting for an IOB. Calling `sem_post()` when the count is less than zero does additional things:
>
> 1. It will unblock the highest priority waiting thread, and
> 2. It will execute priority inheritance logic to restore the priority of threads holding a count
>
> If `sem_post()` is replaced with an increment of the count, then this functionality will not be performed. Is it needed? I think so but would like to hear the thoughts of others. Is there some reason why you expect the count to be >= in all cases? What if other threads are waiting for an IOB? They will not be awakened.
>
> I don't fully understand the failure condition. What do you expect should happen? Doesn't this change just fail to wake up a waiting thread? That might avoid an deadlock, but would still not be correct behavior.
>
> There is too much I do not understand.
>
if there are two or more throttled wait, whether other `sem_wait()` should be awakened by other `sem_post()` in `iob_free()`, which is safer?
--
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