Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Nov 2004 19:15:13 -0500 (EST)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        phk@phk.freebsd.dk
Cc:        arch@FreeBSD.org
Subject:   Re: Multi-threading access to device drivers.
Message-ID:  <200411070015.iA70FDxm015465@khavrinen.lcs.mit.edu>
In-Reply-To: <10847.1099784360@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <10847.1099784360@critter.freebsd.dk> you write:
>Assume a process with two threads on two CPUs, both
>doing read(fd, buf, len) at the same time.
>
>Should we let both reads into the driver at the same time ?
>
>If so, which uio_offset do we hand them ?

POSIX is quite clear on the matter:

> All of the functions chmod (), close (), fchmod (), fcntl (), fstat
> (), ftruncate (), lseek (), open (), read (), readlink (), stat (),
> symlink ( ), and write ( ) shall be atomic with respect to each other
> in the effects specified in IEEE Std 1003.1-2001 when they operate on
> regular files. If two threads each call one of these functions, each
> call shall either see all of the specified effects of the other call,
> or none of them.

(One of the "specified effects" is advancing the file offset.)

-GAWollman

-- 
Garrett A. Wollman   | As the Constitution endures, persons in every
wollman@lcs.mit.edu  | generation can invoke its principles in their own
Opinions not those of| search for greater freedom.
MIT, LCS, CRS, or NSA| - A. Kennedy, Lawrence v. Texas, 539 U.S. ___ (2003)



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