bakkeby / dusk

Just another fork of dwm
MIT License
140 stars 21 forks source link

BSD support #9

Open bakkeby opened 2 years ago

bakkeby commented 2 years ago

There is currently no support for BSD in dusk because the IPC (inter-process communication) implementation uses epoll which is a very Linux centric facility for I/O event notification.

The IPC logic is used to allow the dusk client (duskc) to communicate with dusk to run commands, set the status, get information, etc.

One option would be to port the IPC patch (github) to use the cross-platform libevent library to handle the lower end communication (epoll, kqueue, etc.). There is also a smaller libev library, but this is not so readily available on all platforms to my knowledge.

Alternatively one could use the kqueue library directly and have compile time flags to switch between the kqueue or epoll implementation. Dropping IPC altogether would be less than ideal.

This may be a waste of effort if there is no interest in support for BSD of course so add a 👍🏻 to this issue to show interest.

If you would like to get involved regarding this then that would be most appreciated.

explosion-mental commented 2 years ago

what about using poll? I had a bit of fun (annoyance) figuring out how to implement it in my build, but it is very straight foward.

bakkeby commented 2 years ago

https://www.freebsd.org/cgi/man.cgi?query=poll&manpath=FreeBSD+13.0-RELEASE+and+Ports https://man7.org/linux/man-pages/man2/poll.2.html

Considering that the IPC patch only uses a single file descriptor there shouldn't be any real downsides to using traditional poll in this context.

This page (and associated videos) explain the difference between poll, select and epoll: https://www.softprayog.in/programming/io-multiplexing-select-poll-epoll-in-linux

What is interesting on that page is that there is example code implemented in both poll and epoll so that they can be compared and it is primarily the monitoring code that is different.

explosion-mental commented 2 years ago

Considering that the IPC patch only uses a single file descriptor there shouldn't be any real downsides to using traditional poll in this context.

Yes, but remember that poll can handle multiple fds. I think epoll has the ability to store some kind of data (i think i saw 64, 32 and 16 for it) and that would be one major difference between plain poll, which only monitors file descriptors 'state' (for writting or reading).

While searching about this those links would been so useful.. What I did stumble across was that 'poll is prefered over select'.

Might interest you an example, the run function in my build it's all I do with poll.

explosion-mental commented 2 years ago

just throwing out that the cool kids now use io_uring :p

bakkeby commented 2 years ago

Note to self; have a closer look at how the IPC implementation in https://github.com/JLErvin/berry is done.


Edit: the implementation there is similar to that of the fsignal patch for dwm, just that they don't use the root window name but a SubstructureRedirectMask event sent for the root window. As such all communication goes via the X server which will likely have some impact on performance, but that may be irrelevant in the grand scheme of things. It is a one-way communication though which would make it more cumbersome to get data out of the window manager.