Is it possible to share a semaphore (or any other synchronization lock) between user space and kernel space? Named POSIX semaphores have kernel persi
One solution I can think of is to have a /proc
(or /sys
or whatever) file on a main kernel module where writing 0
/1
to it (or read from/write to it) would cause it to issue an up
/down
on a semaphore
. Exporting that semaphore allows other kernel modules to directly access it while user applications would go through the /proc
file system.
I'd still wait to see if the original question has an answer.
I was thinking about ways that kernel and user land share things directly i.e. without syscall/copyin-out cost. One thing I remembered was the RDMA model where the kernel writes/reads directly from user space, with synchronization of course. You may want to explore that model and see if it works for your purpose.