Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Apr 1999 02:52:56 +0200 (MET DST)
From:      Olaf Wagner <wagner@luthien.in-berlin.de>
To:        freebsd-current@freebsd.org
Subject:   Re: cvsup
Message-ID:  <199904170052.CAA31420@luthien.iceflower.in-berlin.de>
In-Reply-To: <XFMail.990413162255.jdp@polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <XFMail.990413162255.jdp@polstra.com> you wrote:
> Daniel Eischen wrote:
>> John Polstra wrote:
>> 
>>> My hunch is that it's not a fairness issue.  It's just the fact that
>>> when you block in disk I/O, the whole process (all threads) blocks.
>> 
>> That statement made me think that Modula-3 had it's own threading
>> support because our native threads using non-blocking file I/O.

> For disk I/O?  Are you sure?  If so then it must use the aio/lio calls
> or something similar.  Disk I/O calls _always_ block, even if you've
> set O_NONBLOCK on the file descriptor.

The SchedulerPosix interface in m3core exports the procedures
IOWait() and IOAlertWait(), which can be used to wait for
a single file descriptor without stopping other threads.
These procedures are used in FilePosix.IntermittentRead to
implement non-blocking reading. The default implementation
does not count RegularFiles as intermittent readers and
writers though:

REVEAL
  Pipe.T = IntermittentFile BRANDED OBJECT END;
  Terminal.T = IntermittentFile BRANDED OBJECT END;
  RegularFile.T = RegularFile.Public BRANDED OBJECT OVERRIDES
    read := RegularFileRead;
    write := RegularFileWrite;
    seek := RegularFileSeek;
    flush := RegularFileFlush;
    lock := RegularFileLock;
    unlock := RegularFileUnlock
  END;

So read calls on files always block until the Unix read call
returns; no other threads can run.

If the O_NONBLOCK flag on fds would work for disk I/O in FreeBSD,
then the code from the intermittent read procedures in FilePosix
could easily be used to let the scheduler run other threads
while one thread is waiting for data from a file. As John Polstra
pointed out, this seems not to be possible...

Aio could probably be used, but there seems to be a shortage of
man pages about aio calls in FreeBSD and I haven't got my Posix
book at hand, so I'm not sure how difficult this would be.
-- 
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|| Olaf Wagner           | wagner@luthien.in-berlin.de (private) |
|| Cranachstrasse 7      | wagner@elego.de (business)            |
|| D-12157 Berlin        | phone: +49 30  85 60 26 70            | 
|| Germany / Deutschland | fax:   +49 30  85 60 26 71            | 
\/////////////////////////////////////////////////////////////////


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904170052.CAA31420>