Skip site navigation (1)Skip section navigation (2)
Date:      12 Apr 1999 17:01:50 +0300
From:      Ville-Pertti Keinonen <will@iki.fi>
To:        dillon@apollo.backplane.com (Matthew Dillon)
Cc:        hackers@freebsd.org
Subject:   Re: read() and pread() syscalls
Message-ID:  <86hfqmgcoh.fsf@not.demophon.com>
In-Reply-To: dillon@apollo.backplane.com's message of "12 Apr 1999 04:27:16 %2B0300"
References:  <Pine.BSF.4.05.9904112120340.35407-100000@janus.syracuse.net> <199904120126.SAA11924@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help

dillon@apollo.backplane.com (Matthew Dillon) writes:

> :> But, see above about it not being possible to emulate read() with pread()
> :> in userspace.
> :
> :You mean, without lseek(2) =)
> 
>     pread/pwrite + lseek is not atomic, so exact emulation is not
>     possible.

This may come as a shock to you, but read(2)/write(2) aren't atomic in
updating the file pointer, either.

Actually, read(2) is equivalent to lseek(2)+pread(2)+lseek(2), with the
last lseek(2) being SEEK_CUR by the read count returned by pread(2).
The difference is that read(2) can only be pre-empted if it blocks
doing I/O (which is not unusual).

Of course emulating read(2) would be ugly and slow.


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




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