Skip to content

Is kernel event queueing per-process? #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tal-zvon opened this issue Mar 1, 2021 · 1 comment
Closed

Is kernel event queueing per-process? #50

tal-zvon opened this issue Mar 1, 2021 · 1 comment

Comments

@tal-zvon
Copy link

tal-zvon commented Mar 1, 2021

Just looking for a bit of clarification here.

From what I understand, this is how it works:

  • When a GPIO pin's state changes (a button is pressed, or whatever), the CPU gets an interrupt, and the kernel is notified
  • The kernel checks if anyone is registered to be alerted of that pin's state change
  • If so, they have a dedicated queue that the event will be added to

Importantly, this queue is per-process.
As in, when our Rust application starts up, and uses gpio_cdev to register to be notified about a pin state change with:

let handle = chip.get_line(N)?.request(LineRequestFlags::INPUT, 0, "read-input")?;

The kernel sets up a queue specifically for this process, for this one line.

The alternative, which I'm really hoping isn't the case, is that there's one queue per line that the kernel maintains, and when your Rust application starts, and registers to be notified, the queue may already have events in it that may potentially need to be discarded.

@posborne
Copy link
Member

The kernel has a queue per LineRequest which are not shared between processes. You should even be able to have multiple per process if you have a use case for that.

https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpiolib-cdev.c#L469

Note that if the FIFO fills, events will be dropped:

https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpiolib-cdev.c#L523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants