From: Mark Mielke <mark@mark.mielke.cc>
To: Mikhail Kruk <meshko@cs.brandeis.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: fcntl file locking and pthreads
Date: Sun, 4 May 2003 17:29:59 -0400 [thread overview]
Message-ID: <20030504212959.GB12243@mark.mielke.cc> (raw)
In-Reply-To: <Pine.LNX.4.33.0305040206270.20509-100000@iole.cs.brandeis.edu>
On Sun, May 04, 2003 at 02:13:25AM -0400, Mikhail Kruk wrote:
> on 2.4 kernels fcntl-based file locking does not work with
> clone-based threads as expected (by me): two threads of the same process
> can acquire exclusive lock on a file at the same time.
> flock()-based locks work as expected, i.e. only one thread can have an
> exclusive lock at a time.
> What would it take to make fcntl work as flock?
I don't think per-thread locks is entirely reasonable. The file descriptor
is shared between threads, which means that attributes (including locks)
attached to the file descriptor, are shared between threads.
I would suggest that system resources such as advisory locks be considered
per process, and inter-thread synchronization be performed using thread
synchronization primitives such as the mutex. Feel free to quote from POSIX
to tell me that this suggestion is wrong.
mark
--
mark@mielke.cc/markm@ncf.ca/markm@nortelnetworks.com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
http://mark.mielke.cc/
next prev parent reply other threads:[~2003-05-04 21:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-04 6:13 fcntl file locking and pthreads Mikhail Kruk
2003-05-04 12:58 ` Jamie Lokier
2003-05-04 13:25 ` Mikhail Kruk
2003-05-04 15:24 ` Miquel van Smoorenburg
2003-05-04 18:40 ` David Schwartz
2003-05-04 19:29 ` Mikhail Kruk
2003-05-04 20:55 ` David Schwartz
2003-05-04 21:50 ` Mikhail Kruk
2003-05-04 21:29 ` Mark Mielke [this message]
2003-05-04 21:56 Ville Voutilainen
2003-05-04 22:04 ` Mikhail Kruk
2003-05-04 22:29 Ville Voutilainen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030504212959.GB12243@mark.mielke.cc \
--to=mark@mark.mielke.cc \
--cc=linux-kernel@vger.kernel.org \
--cc=meshko@cs.brandeis.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).