From owner-freebsd-current Fri Apr 16 17:57:25 1999 Delivered-To: freebsd-current@freebsd.org Received: from frosch.all.de (frosch.all.de [212.21.72.2]) by hub.freebsd.org (Postfix) with ESMTP id AE2CC1528F for ; Fri, 16 Apr 1999 17:57:20 -0700 (PDT) (envelope-from luthien.iceflower.in-berlin.de!wagner@bolzen.denic.net) Received: from bolzen.denic.net (root@bolzen.all.de [212.21.76.1]) by frosch.all.de (8.9.0/8.9.0) with ESMTP id CAA01141 for ; Sat, 17 Apr 1999 02:54:52 +0200 (CEST) Received: by bolzen.denic.net (Smail3.2) id ; Sat, 17 Apr 1999 02:47:21 +0200 (MET DST) Received: (from wagner@localhost) by luthien.iceflower.in-berlin.de (8.9.2/8.8.3) id CAA31420; Sat, 17 Apr 1999 02:52:56 +0200 (MET DST) Date: Sat, 17 Apr 1999 02:52:56 +0200 (MET DST) From: Olaf Wagner Message-Id: <199904170052.CAA31420@luthien.iceflower.in-berlin.de> To: freebsd-current@freebsd.org Subject: Re: cvsup In-Reply-To: User-Agent: tin/pre-1.4-19990216 ("Styrofoam") (UNIX) (FreeBSD/3.1-STABLE (i386)) Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article 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