NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Matching file to a physical medium

On Fri, 15 Oct 2010 09:16:17 +0200
Matthias Kretschmer <> wrote:

> Hello,
> On Fri, Oct 15, 2010 at 12:33:01AM +0100, Sad Clouds wrote:
> > Well, one of the problems I'm trying to solve is what to do in a
> > multi-threaded process, when threads access files and block forever,
> > because some file are on NFS and the network goes down.
> > 
> > Ideally I would like a thread to issue a system call, time it for a
> > number of microseconds and if there is no progress, abort the system
> > call.
> > 
> > I'm struggling to find a good way to do it, because simply calling
> > pthread_cancel() does not work. I'm not aware of any facility in
> > Unix to abort a system call, maybe Unix signals can help, but I'd
> > rather not mix signals and threads.
> what about using select(2), kqueue(2) or poll(2) with a corresponding
> timeout?

You talk about I/O multiplexing, I don't think this will work with
regular files. This works for sockets, because you can set a socket
descriptor non-blocking, however setting a regular file descriptor
non-blocking has no effect. Anyway, what happens if your application
hangs even before it had a chance to obtain a file descriptor, i.e.
calling open() on a dead NFS mount.

Home | Main Index | Thread Index | Old Index