Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 98 09:19:06 -0600
From:      "Richard Seaman, Jr." <lists@tar.com>
To:        "Marc Slemko" <marcs@znep.com>
Cc:        "hackers@freebsd.org" <hackers@FreeBSD.ORG>
Subject:   Re: pread/pwrite
Message-ID:  <199812111519.JAA45380@ns.tar.com>

next in thread | raw e-mail | index | archive | help
On Thu, 10 Dec 1998 14:20:22 -0800 (PST), Marc Slemko wrote:

>(not necessarily addressed specifically at pread/pwrite, but it does
>apply to it because of how it is used...)
>
>Where is the locking if multiple threads are reading and/or writing
>from or to the same descriptor at the same time?  If you have x
>threads reading from a descriptor opened from a file on disk, do
>x-1 of them have to wait until the first one finishes before they can
>do anything?
>
>What about with mixed reading/writing?

Well, I'm no expert on the FreeBSD kernel, and know even less about
FreeBSD SMP.  But, here's my understanding (and I hope someone will
correct me if I'm wrong).

In the uniprocessor case, it is my understanding that the kernel
is nonpreemtive.  Thus, if pread/pwrite are syscalls, no locking
is needed any more than it is needed for read/write.

In the SMP case, you need locking, I think.  My understanding is
that FreeBSD currently has a kernel "giant lock".  Moving to
more fine grained locking could require locking fd's, but
as long as that is not implemented for read/write, I don't
see that its needed for pread/pwrite.

If I'm wrong about this, then the pread/pwrite implementation
I've supplied is not correct.

And, based on this, I think read/write (or pread/pwrite) is
effectively ordered (one thread at a time accessing an fd) by
the nature of the kernel (uniprocessor) or by the locks (SMP).




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?199812111519.JAA45380>