If one thread (say X) is waiting on an epoll_wait()
can another thread (say Y) makes a call to epoll_ctl()
to register interest in file descriptor 9
. Can the previous call to epoll_wait()
in thread X return the file descriptor 9
added by thread Y? The initial call to epoll_wait()
never returned in the middle at any point.
Now I want to compare this and ask related questions with respect to two other polling calls in operating systems. poll()
and kqueue
- If the answer to the above question is true then is there a way to achieve similar behavior with the
poll()
system call? - Let us assume that
epoll_ctl()
is thread safe and thread X can safely callepoll_ctl()
and have the call toepoll_wait()
return whether the file descriptor9
is ready for I/O. The separation of the function to declare interest in the file descriptor and the function to wait is what would make this function amazing. But people often refer thekqueue
andepoll
as being used for the same functionality. Howeverkqueue
does not have a separate function to declare interest in getting event feedback for a descriptor. Does anybody know howkqueue
can be used in a similar manner asepoll
?epoll
seems to be the best threadsafe option out there right now if it allows threadsafe "interest declaration"