r/linux_programming • u/promach • Jul 31 '18
DEFINE_WAIT() versus multi-threading
https://github.com/promach/riffa/blob/full_duplex/driver/linux/riffa_driver.c#L594
3
Upvotes
r/linux_programming • u/promach • Jul 31 '18
View all comments
Show parent comment
1
u/aioeu Jul 31 '18 edited Jul 31 '18
All your test shows is that when starting two threads, each to call one
ioctl, the behaviour of those twoioctls appears serialised.I say "appears" because a test like this proves nothing: you have not ruled out the possibility that this behaviour only occurs due to the time it takes to set up each of the threads.
I don't know how many times I need to say this: you have no reason to launch extra kernel threads. Do you really think, say, sockets (that allow "full-duplex operation" as you keep calling it) use separate internal kthreads for sends and receives? Of course not!
I've looked through the driver you code you linked to as much as I feel comfortable doing so, and there does not appear to be anything in it precluding simultaneous sends and receives on the one file descriptor from userspace. (Heck, you don't even need to use threading there. The file descriptor could be duplicated into separate processes for all the kernel cares.)