io_uring in multithreaded process

1.8k Views Asked by At

I am trying to write a multithreaded server using io_uring. The problem is the function 'io_uring_wait_cqe' requires calling to io_uring_cqe_seen to mark the CQE as seen.

Therefore, in several threads, there may be a situation where the same event is handled in several threads.

Of course, I don't want to use locks, mutex, etc.

What is the best way to work with several threads?

1

There are 1 best solutions below

0
Mascarpone On

the official suggestion from jens axboe is to prefer to use one io_uring per thread. If for some reason you really need thread synchronization an approach could be to have one worker thread that uses io_uring, and other threads use message passing to talk with the working thread.