All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Friesen <cfriesen@nortelnetworks.com>
To: Matthew Wilcox <willy@debian.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: fcntl and flock wakeups not FIFO?
Date: Mon, 17 Feb 2003 23:51:15 -0500	[thread overview]
Message-ID: <3E51BBC3.503@nortelnetworks.com> (raw)
In-Reply-To: 20030218010054.J28902@parcelfarce.linux.theplanet.co.uk

Matthew Wilcox wrote:
 > [cc'ing the person or list mentioned in MAINTAINERS would get you
 > a better response :-P]

Hmm...that might be a good idea.  :)

 >>I've been doing some experimenting with locking on 2.4.18 and have
 >>noticed that if I have a number of writers waiting on a lock, they are
 >>not woken up in the order in which they requested the lock.
 >>
 >>Is this expected? If so, what was the reasoning for this and are there
 >>any patches to give FIFO wakeups?
 >
 >
 > That certainly isn't what's supposed to happen.  They should get woken
 > up in-order.  The code in 2.4.18 seems to be doing that.  Are you
 > doing anything clever with scheduling?

Well maybe a little bit on the production box, but I don't think its the
cause since the same thing happens on my home machine with a stock
Mandrake 9 kernel (2.4.19-16mdk).

Here's the test app:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/file.h>

int main(int argc, char **argv)
{
     int fd = open("/dev/null", O_RDWR);
     if (fd < 0)
     {
        perror("open");
        exit(-1);
     }

     printf("aquiring exclusive lock\n");
     int rc = flock(fd, LOCK_EX);
     if (rc < 0)
     {
        perror("flock");
        exit(-1);
     }

     printf("got lock\n");

     while(1)
        pause();

     return 0;
}

I start up four different instances of it in different windows, then
kill them (ctrl-c) in the order that I started them.

It doesn't happen every time, but they don't always get the lock in the
same order that I started them.

Chris




  reply	other threads:[~2003-02-18  4:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-18  1:00 fcntl and flock wakeups not FIFO? Matthew Wilcox
2003-02-18  4:51 ` Chris Friesen [this message]
2003-02-18 14:44 ` Chris Friesen
2003-02-18 15:02   ` Matthew Wilcox
2003-02-18 19:00     ` Chris Friesen
  -- strict thread matches above, loose matches on Subject: below --
2003-02-17 19:11 Chris Friesen

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=3E51BBC3.503@nortelnetworks.com \
    --to=cfriesen@nortelnetworks.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@debian.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.