According to POSIX poll
, it says POLLPRI
:
High-priority data may be read without blocking.
It is a special read event, likely to read OOB data, etc.
Now in Linux, if /sys/class/gpio/gpio<N>/value
is opened and listened for POLLIN
via poll
or register in readfds
for select
, the event is permanent and these function exit continuously without waiting for an actual interrupt. For receiving actual interrupts in user-space, one must register for POLLPRI
in poll()
/epoll()
or exceptfds
in select()
. In fact, kernel documentation for GPIO sysfs interface explicitly asks for this. If dug deeper, gpiolib eventually raises a sysfs_notify()
on the value
file which is what translates as POLLPRI
in user-space.
My understanding is, from the time of interrupt to the time when user-space read()
s, the value of GPIO could've changed. It's not like most GPIO devices are regulated by a clock and synchronized with CPU anyway. So the kernel can only tell user-space that 'something happened' on the GPIO line and may not be able to tell with absolute guarantee that the 'state has now changed and that it's worthy of reading'. So raising POLLPRI
without POLLIN
seems logical.
So my questions are:
- Is
sysfs_notify()
raisingPOLLPRI
without also raisingPOLLIN
a bug in Linux? Author oflibev
claims it is a design bug, but I cannot find any other document suggesting it is so. - Can
POLLPRI
be independent ofPOLLIN
? POSIX does not explicitly say so, nor have I come across another subsystem doing something like this.