PgrAm wrote:
- Make sure the ring buffer is mapped into the kernel space of every process, this seems like a hell of alot of overhead for allocating a ring buffer, meaning I have to find all the running processes and allocate inside them
Most operating systems only change the mapping for userspace when switching between address spaces, the mapping for kernelspace in each process remains identical, so the kernel can map the buffer that the interrupt handler deals with once and have access to it whichever process is currently running.
You may still want to have a separate buffer for each process (all mapped into kernel space where the kernel can see them whichever process is running), though. What happens if the user types a few keystrokes, but the process in focus doesn't read them until the user switches another process into focus? If you just have one keyboard buffer for the whole system, a process could receive keystrokes that the user did not intend for it, and the process they were intended for might never receive them.