triggering user space with kernel

前端 未结 3 705
感动是毒
感动是毒 2021-01-20 18:25

I need to send a string from kernel to a user space function without asking for it in particular from the user space, sort of triggering a function or application in the use

3条回答
  •  离开以前
    2021-01-20 18:54

    You've got a few options:

    1. Signals. User process defines a signal handler, and kernel signals the user process upon receipt of an event. This works well, but requires that the handling code run in an async signal handler (which makes it trickier to write correct code). The downside is that the amount of data you can transmit using a signal handler is somewhat limited. Make sure to use a signal that can be queued (e.g. a realtime signal) so you don't lose messages when the process is in the middle of handling a signal.
    2. Blocking system call or file access. User process executes a system call (or reads/writes a file) which puts it to sleep. The kernel driver for the call maintains a queue of events, and dequeues events when they arrive and when a blocked waiter exists (this avoids losing events when the user process is unblocked).
    3. Create a system call which configures a sigevent. On the kernel side, create a sigqueue to fire the relevant events.

提交回复
热议问题