Executing a user-space function from the kernel space

前端 未结 4 628
一整个雨季
一整个雨季 2020-12-03 19:19

Im writing a custom device driver in linux that has to be able to respond very rapidly on interrupts. Code to handle this already exists in a user-space implementation but t

4条回答
  •  无人及你
    2020-12-03 19:51

    I think the easiest way is to register a character device which becomes ready when the device has some data.

    Any process which tries to read from this device, then gets put to sleep until the device is ready, then woken up, at which point it can do the appropriate thing.

    If you just want to signal readyness, a reader could just read a single null byte.

    The userspace program would then just need to execute a blocking read() call, and would be blocked appropriately, until you wake it up.

    You will need to understand the kernel scheduler's wait queue mechanism to use this.

提交回复
热议问题