4 ms·
Don't mutexes provide, well, mutual exclusion, so that some operations would be forced to be single-threaded?
by Joker_vD 3y ago
Don't mutexes provide, well, mutual exclusion, so that some operations would be forced to be single-threaded?
- bluGill 3y agoRight, but if done right you rarely are in a situation two threads want to share the thread, so in practice you are not. However doing this right is difficult.
- toast0 3y agoYeah, but most of the things that need exclusivity or consistency are relatively rare or very narrow. You need consitency when you update the socket tables. (Relatively rare, but can be a bottleneck for use cases with frequent open/close and maybe accept) You need exclusivity when send or recieve on tcp sockets. (Very narrow) You also need exclusivity when putting packets one of on the NIC's sendqueues. That one's not really rare, better NICs have more queues for less contention though. For really high volume packet processing, it's helpful to align socket processing so everything is pinned to the same core: nic interrupts, kernel rx, application read and processing, application send, kernel tx, etc. But last I checked OpenBSD doesn't do cpu pinning, so there's that.