mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <andrewm@uow.edu.au>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: Multithreaded locks.c
Date: Sun, 05 Nov 2000 10:57:57 +1100	[thread overview]
Message-ID: <3A04A285.3CA6FD37@uow.edu.au> (raw)
In-Reply-To: <3A042031.A170B555@uow.edu.au> from "Andrew Morton" at Nov 05, 2000 01:41:53 AM <E13s7vQ-0004hr-00@the-village.bc.nu>

Alan Cox wrote:
> 
> > have got it right.  Does anyone know what this part of the
> > flock(2) manpage means?
> >
> >        A  single file may not simultaneously have both shared and
> >        exclusive locks.
> 
> AFAIK its saying LOCK_EX is exclusive and blocks shared locks and vice
> versa.  Its a standard reader-writer lock setup. LOCK_EX is writer, LOCK_SH
> is reader.

Thanks, Alan.  You're right, and this is indeed how the current
implementation behaves.  The DG/UX manpage makes a bit more sense
here.

One interesting factoid: if a process currently has an exclusive
lock, and it changes that to an exclusive lock (ie: no change),
this has the effect of dropping the lock and reclaiming it.

The DG/UX dg_flock() departs from BSD in that "Upgrading a lock 
will be an atomic operation.  That is, a lock is not released
to upgrade that lock".  Linux doesn't do that - the lock is
effectively dropped and reclaimed when we go from LOCK_SH to LOCK_EX.

Even the DG/UX manpage doesn't say what happens when you sidegrade
the lock.  LOCK_EX->LOCK_EX :)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-11-04 23:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-04 14:41 Andrew Morton
2000-11-04 18:20 ` Alan Cox
2000-11-04 23:57   ` Andrew Morton [this message]
2000-11-05  0:34     ` yodaiken

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=3A04A285.3CA6FD37@uow.edu.au \
    --to=andrewm@uow.edu.au \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®