From owner-freebsd-arch@FreeBSD.ORG Thu Apr 3 07:17:27 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B665637B401 for ; Thu, 3 Apr 2003 07:17:27 -0800 (PST) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5EF0A43FBF for ; Thu, 3 Apr 2003 07:17:26 -0800 (PST) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id h33FHKmF005318; Thu, 3 Apr 2003 19:17:24 +0400 (MSD) Date: Thu, 3 Apr 2003 19:17:20 +0400 (MSD) From: Igor Sysoev X-Sender: is@is To: Terry Lambert In-Reply-To: <3E8C42EE.C3602A39@mindspring.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-arch@freebsd.org Subject: Re: libthr and 1:1 threading. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2003 15:17:28 -0000 On Thu, 3 Apr 2003, Terry Lambert wrote: > > > O_NONBLOCK. > > > > > > Examining the Solaris 8 sources, it seems to have been removed from > > > the disk I/O modules, and applies only to socktpi.c, ptm.c, audio_mc.c, > > > ecpp.c, and envctrl.c. Apparently, it's also missing from the tty > > > code, which goes against what Matt claimed, actually. > > > > If Solaris 8's stdin handled by tty code then tty supports O_NONBLOCK: > > [ ... test program ... ] > > Now try redirecting input from a file. O_NONBLOCK is a flag; the > system doesn't care if you are setting it on a file, a tty, the > parallel port, or the PTY master; it's just a flag. And what do you suppose to see in this case ? ---------- >cat t1.c #include #include #include #include void print_time(char *string, struct timeval *tp0, struct timeval *tp1) { long sec, usec; sec = tp1->tv_sec - tp0->tv_sec; if ((usec = tp1->tv_usec - tp0->tv_usec) < 0) { usec += 1000000; sec--; } printf("%s time: %u.%06u\n", string, sec, usec); } main() { int rc; char buf[1024]; struct timeval tv0, tv1; if ((rc = fcntl(0, F_GETFL)) == -1) { printf("fcntl(F_GETFL) failed: %d: %s\n", errno, strerror(errno)); exit(1); } if ((rc = fcntl(0, F_SETFL, rc | O_NONBLOCK)) == -1) { printf("fcntl(F_SETFL) failed: %d: %s\n", errno, strerror(errno)); exit(1); } gettimeofday(&tv0, NULL); if ((rc = read(0, buf, 1024)) == -1) { printf("read() failed: %d: %s\n", errno, strerror(errno)); } gettimeofday(&tv1, NULL); print_time("read", &tv0, &tv1); } >./t1 read() failed: 11: Resource temporarily unavailable read time: 0.000351 >./t1 < /kernel/genunix read time: 0.005157 >./t1 < /kernel/genunix read time: 0.000019 ---------- When /kernel/genunix was not cached a read() takes 5157 usec's. And no EAGAIN error. > Matt's first argument is that the flag has no effect on disk files > in FreeBSD; I don't dispute that, and never did. Not only in FreeBSD. Linux and Solaris do the same. > His second argument is that if it starts having an effect, there > is code that people have written that depends on it not having an > effect, and where they handle every possible error return listed > on the man page and in the POSIX.1 standard, *except* EAGAIN. And > this code will break, and that breakage is a violation of POLA. > > I happen to disagree with this second argument. The most Unices ignore O_NONBLOCK for disk files. So I think programmers never use this flag and select()/etc for disk files (because it's useless) and I think supporting this flag for disk files should not break existent software. But of course it creates portability problems. > > This Solaris 2.4's readv() man > > http://www.doc.ic.ac.uk/~mac/manuals/solaris-manual-pages/solaris/usr/man/man2/read.2.html > > states that O_NONBLOCKed regular disk file can return EAGAIN only > > if there is a mandatory file/record lock. Solaris 8's man states the same. > > Actually, ity does not say "only". It also says: > > EAGAIN Total amount of system memory available when > reading using raw I/O is temporarily insuffi- > cient. Yes, but there's no word about EAGAIN while a reading from a disk. > > > Or the USL SVR4.0.2 or SVR4.2 source code? > > > > No, I have not an access to this source code. > > But if you have an access to these systems it's easy to check whethear > > these systems supports O_NONBLOCK on disk files or not. > > Try redirecting your test program from a file. It's just a flag. > My Solaris 8 source code and Solaris 8 SPARC box both allow it > to be set on a file, even if it has no effect. See above. Igor Sysoev http://sysoev.ru/en/