2

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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Rachel91
  • 59
  • 4

1 Answers1

0

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.

Mascarpone
  • 2,516
  • 4
  • 25
  • 46