[MPlayer-dev-eng] Re: kernel: to do_select(pipe) or not to do
D Richard Felker III
dalias at aerifal.cx
Mon Nov 22 23:02:04 CET 2004
On Mon, Nov 22, 2004 at 06:26:16PM +0100, Gábor Lénárt wrote:
> On Mon, Nov 22, 2004 at 10:35:52AM -0500, D Richard Felker III wrote:
> > > As I already mentioned, "select()" usage ONLY MAKES SENSE FOR NONBLOCKING
> > > FILE DESCRIPTORS.
> > >
> > > Of _course_ a write() will block if the fd is blocking. But if you have a
> > > nonblocking fd it will NOT block.
> >
> > a write should never block if select indicated that the fd was
> > writeable. it should write however many bytes can be written
>
> Maybe I'm wrong at this point but what about if you got "fd is
> writeable" from select but before reaching write() another
> thread got control and writes something?
this is not a problem unless you have more than one process/thread
writing the same fd at the same time, in which case you're either a
total idiot or you've already carefully thought out what should
happen. more likely the former if you're using threads to begin
with... :)
> I mean: use select() _THEN_
> write() is not an atomic operation of course so race condition
> can be experienced here. I'm assuming this because of Linux
> specific clone() system call (CLONE_FILES flag) which is/can be
> used to create threads.
>
> But this whole blocking/non-blocking issue from the point of
> view of the kernel is quite unknown for me, so maybe I'm wrong.
you're just asking about something entirely unrelated to the topic at
hand.
rich
More information about the MPlayer-dev-eng
mailing list