Commit graph

5 commits

Author SHA1 Message Date
Marcin Niestroj
add51d809c tests: posix: eventfd: test read and poll after multiple writes
When there were multiple writes to eventfd, then poll() + read() should
start behaving as just initialized. Test that by verifying poll() will
timeout first and later be notified properly when eventfd is written
once again from the other thread.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-20 16:21:37 +02:00
Anas Nashif
1200222ff8 test: posix: fix identifier
Follow convention for identifying tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-25 22:36:17 -05:00
Marcin Niestroj
398f22b34a tests: eventfd: drop POSIX_API ifdeffery
Test is configured with CONFIG_POSIX_API=y, so there is no reason to
check for it being enabled in C. Additionally when CONFIG_POSIX_API=n a
much "bigger" posix/sys/socket.h was included instead of net/socket.h,
which should be rather opposite.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-25 12:14:40 +02:00
Paul Sokolovsky
32270ae1b9 tests: posix: eventfd: Don't mix POSIX and Zephyr kernel APIs
K_MSEC() shouldn't be used with poll(), as they come from 2 different
API domains.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Tobias Svehagen
ca872a44c1 lib: posix: Add support for eventfd
This implements a file descriptor used for event notification that
behaves like the eventfd in Linux.

The eventfd supports nonblocking operation by setting the EFD_NONBLOCK
flag and semaphore operation by settings the EFD_SEMAPHORE flag.

The major use case for this is when using poll() and the sockets that
you poll are dynamic. When a new socket needs to be added to the poll,
there must be some way to wake the thread and update the pollfds before
calling poll again. One way to solve it is to have a timeout set in the
poll call and only update the pollfds during a timeout but that is not
a very nice solution. By instead including an eventfd in the pollfds,
it is possible to wake the polling thread by simply writing to the
eventfd.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-04-28 09:57:41 +03:00