[671] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: NONBLOCKING fcntl

daemon@ATHENA.MIT.EDU (Mark Evans)
Wed Jul 9 19:40:20 1997

Date: Wed, 09 Jul 1997 17:13:48 -0600
From: Mark Evans <mevans@cti-ltd.com>
To: Cheryl Huntington <clh@swdc.stratus.com>
Cc: pthreads@MIT.EDU

Pthreads maintains a separate "user-state" of every fd in use by a
process, while forcing the actual "kernel-state" of all fd's to
be non-blocking.

On every file operation, pthreads checks the returned error.  If the
error is EWOULDBLOCK *and* the "user-state" of the fd is "blocking",
the thread is forfiets the CPU to another thread (thus appearing to
block).  The thread is rescheduled to run when select() indicates
that the fr is "ready" for the requested operation.

> 
> I've noticed in fd.c, that the function fcntl always sets the fd to be
> NONBLOCKING for F_SETFL. I can see why you wouldn't want blocking in
> threads, but what if the app really needs blocking? Is it reasonable to
> force it to be NONBLOCKING?
> 
> Cheryl
> 
> --
>    Cheryl Huntington        clh@swdc.stratus.com        408-559-5665
> Stratus  Western  Development  Center,  Commands  and  Utilities  Group

--
Mark Evans                                  Where do I want to go?
Conservation Through Innovation Ltd.        http://www.linux.org

home help back first fref pref prev next nref lref last post