On Wed, Feb 8, 2023 at 6:31 PM Carlos Sanchez
<carlossanc...@geotab.com.invalid> wrote:

> Hi all,
>
> If I understand correctly the POSIX standard, events using
> SIGEV_THREAD notification should behave as threads created using
> pthread_create. Quoting the standard:
>
> ---- QUOTE BEGIN ----
> Multi-threaded programs can use an alternate event notification
> mechanism. When a notification is processed, and the sigev_notify
> member of the sigevent structure has the value SIGEV_THREAD, the
> function sigev_notify_function is called with parameter sigev_value.
>
> The function shall be executed in an environment as if it were the
> start_routine for a newly created thread with thread attributes
> specified by sigev_notify_attributes. If sigev_notify_attributes is
> NULL, the behavior shall be as if the thread were created with the
> detachstate attribute set to PTHREAD_CREATE_DETACHED. Supplying an
> attributes structure with a detachstate attribute of
> PTHREAD_CREATE_JOINABLE results in undefined behavior. The signal mask
> of this thread is implementation-defined.
> --- QUOTE END ----
>
> However, in Nuttx, the functions are sent to the work queues, which
> are tasks which do not belong to the same task group as the main task
> so the file descriptors are not shared. This makes it difficult to
> implement code that reads from a file (device node) when a timeout
> happens.
>
> I think this is a deviation from the POSIX standard, is there any kind
> of document listing known deviations?
>
>
Yes, it's a well known limitation documented here:
https://github.com/apache/nuttx/issues/1352.


> Possible solutions:
> - Create another work queue for timers which belongs to the same task
> group as the main task.
> - Use nx_pthread_create internally for notification actions instead of
> work queues.
>
>
Both are possible solutions. Another one is sent the signal as before and
creates or wakes up the user space thread in the signal handler. One
workaround we are using now is opening a file with file_open or a socket
with psock_socket.


> Thoughts?
>
> BR
>
> Carlos
>
> --
>
> Carlos Sanchez (he, him, his)
> Geotab
>
> Embedded Systems Developer Team Lead | Europe
>
> Visit
>
> www.geotab.com
>
> Twitter | Facebook | YouTube | LinkedIn
>

Reply via email to