|
|
|
|
|
by ori_b
1910 days ago
|
|
> How is that conceptually different from IPC? The graphics system appears to somehow pass mouse and keyboard events to the client programs over a channel. A thread reads them from a file descriptor and writes them to a channel. You can look at the code which gets linked into the binary: /sys/src/libdraw/mouse.c:61
Essentially, the loop in _ioproc is: while(read(fd, event)){
parse(event);
send(mousechan, event);
}
And yes, once you have an open FD, read() and write() act similar to how they would elsewhere. The difference is that there are no OTHER cases. All the code works that way, not just draw events.And getting the FD is also done via 9p, which means that it naturally respects namespaces and can be interposed. For example, sshnet just mounts itself over /net, and replaces all network calls transparently for all programs in its namespace. Because there's no special case API for opening sockets: it's all 9p. |
|
To me the problem with saying "no special cases" seems to make it quite limited on the kernel side and prevent optimization opportunities. For example if you look at the file node vtables on Linux [0] and FreeBSD [1] there are quite a lot of other functions there that don't fit in 9p. So you lose out on all that stuff if you try to fit everything into a 9p server or a FUSE filesystem or something else of that nature.
[0]: https://elixir.bootlin.com/linux/v5.11.8/source/include/linu...
[1]: https://github.com/freebsd/freebsd-src/blob/master/sys/kern/...