From: Phillip Susi <psusi@cfl.rr.com>
To: "Li, Peng" <ringer9cs@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Thread safety for epoll/libaio
Date: Tue, 28 Feb 2006 22:35:50 -0500 [thread overview]
Message-ID: <44051696.7070801@cfl.rr.com> (raw)
In-Reply-To: <598a055d0602281236m7eac9c09oc60af9ce28e7e4bf@mail.gmail.com>
You don't mix epoll with io_submit; they are two completely different
methods for doing IO. The former is for use with bsd style non blocking
IO, and the latter is truly async io. epoll will signal you whenever a
file can be read ( the read ahead buffer is non empty ) or written (
there's memory available to buffer writes ). io_getevents() won't
notify you of anything until you actually request a read or write, in
which case, it lets you know when that has completed.
The two systems are completely non interchangeable. With the former you
wait first, then request some IO, which completes immediately. With the
latter, you request some IO ( possibly many ), then wait for some to
finish.
Li, Peng wrote:
> I apologize if I should not post this on LKML, but there seems to be
> some lack of documentation for using epoll/AIO with threads. Are
> these interfaces thread-safe? Can I use them safely in the following
> way:
>
> Thread A: while(1) { io_getevents(); ... }
> // wait forever until an event occurs, then handles the event and loop
>
> Thread B: while(1) { epoll_wait(); ... }
> // same as thread A
>
> Thread C: ... io_submit(); ...
>
> Thread D: ... epoll_ctl(); ....
>
> Suppose thread B calls epoll_wait and blocks before thread D calls
> epoll_ctl. Is it safe to do so? Will thread B be notified for the
> event submitted by thread D? Thread A and C pose the same question
> for AIO.
>
> I wrote a simple program to test these interfaces and they seem to
> work without problems, but I am not sure if it is really safe to do so
> in general. If all of them works, it seems easy to use epoll and AIO
> together as I can simply use another thread to harvest events from
> thread A and B and make it look like a unified event notification
> interface.
>
> Peng
next prev parent reply other threads:[~2006-03-01 3:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-28 20:36 Thread safety for epoll/libaio Li, Peng
2006-03-01 1:55 ` Anton Titov
2006-03-01 2:27 ` Benjamin LaHaise
2006-03-01 3:35 ` Phillip Susi [this message]
2006-03-01 3:48 ` David Schwartz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44051696.7070801@cfl.rr.com \
--to=psusi@cfl.rr.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ringer9cs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox