[MPlayer-dev-eng] Re: kernel: to do_select(pipe) or not to do

Gábor Lénárt lgb at lgb.hu
Mon Nov 22 18:26:16 CET 2004


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? 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.

- Gábor (larta'H)




More information about the MPlayer-dev-eng mailing list